mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-02-20 15:43:58 -05:00
* Switch from window resize to ref resize * Prevent dragging changing the cursor style * List view improvements * Update layout context * Update useIsTextTruncated hook --------- Co-authored-by: Jamie Pine <32987599+jamiepine@users.noreply.github.com>
12 lines
411 B
TypeScript
12 lines
411 B
TypeScript
import { RefObject, useMemo } from 'react';
|
|
import useResizeObserver from 'use-resize-observer';
|
|
|
|
export const useIsTextTruncated = (element: RefObject<HTMLElement>, text: string | null) => {
|
|
const { width } = useResizeObserver({ ref: element });
|
|
|
|
return useMemo(() => {
|
|
if (!element.current) return false;
|
|
return element.current.scrollWidth > element.current.clientWidth;
|
|
}, [element, width, text]);
|
|
};
|