- ) => (
-
-
-
- {params.row.original.title}
-
-
+
),
[]
);
@@ -320,3 +315,46 @@ const ItemActions = ({ item }: { item: Item }) => {
);
};
+
+const ItemTitle = ({ item }: { item: Item }) => {
+ const ref = useRef(null);
+ const [isOverflown, setIsOverflown] = useState(false);
+
+ useEffect(() => {
+ const checkOverflow = () => {
+ const element = ref.current;
+ // Should always be defined, but just in case.
+ if (element) {
+ setIsOverflown(element.scrollWidth > element.clientWidth);
+ }
+ };
+ checkOverflow();
+
+ window.addEventListener("resize", checkOverflow);
+ return () => {
+ window.removeEventListener("resize", checkOverflow);
+ };
+ }, [item.title]);
+
+ const renderTitle = () => {
+ // We need to have the element holding the ref nested because the Tooltip component
+ // seems to make the top-most children ref null.
+ return (
+
+
+ {item.title}
+
+
+ );
+ };
+ return (
+
+
+ {isOverflown ? (
+ {renderTitle()}
+ ) : (
+ renderTitle()
+ )}
+
+ );
+};