Skip to content

Commit

Permalink
fix(multiselect): calculate scroll width for title for truncation (#1…
Browse files Browse the repository at this point in the history
…4626)

* fix(multiselect): calculate scroll width for title for truncation

* chore: clean up code duplication
  • Loading branch information
alisonjoseph committed Sep 13, 2023
1 parent 3cfbc24 commit 02d81f0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/react/src/components/ListBox/ListBoxMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ function useIsTruncated(ref) {
const [isTruncated, setIsTruncated] = useState(false);

useEffect(() => {
const { offsetWidth, scrollWidth } = ref.current;
const element = ref.current;
const { offsetWidth, scrollWidth } =
element.lastElementChild?.lastElementChild || element;
setIsTruncated(offsetWidth < scrollWidth);
}, [ref, setIsTruncated]);

Expand Down

0 comments on commit 02d81f0

Please sign in to comment.