Skip to content

Commit

Permalink
Removed unnecessary deps and added scroll capturing to bounding rect
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms committed Sep 11, 2023
1 parent 176e294 commit c9b9684
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 1 addition & 8 deletions frontend/src/lib/components/Dropdown/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,7 @@ export const Dropdown = withDefaults<DropdownProps>()(defaultProps, (props) => {
setOptionIndexWithFocusToCurrentSelection();
}
}
}, [
inputBoundingRect,
dropdownVisible,
filteredOptions,
selection,
setOptionIndexWithFocusToCurrentSelection,
setStartIndex,
]);
}, [inputBoundingRect, dropdownVisible, filteredOptions, selection]);

const handleOptionClick = React.useCallback(
(value: string) => {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib/hooks/useElementBoundingRect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function useElementBoundingRect(ref: React.RefObject<HTMLElement>): DOMRe

const resizeObserver = new ResizeObserver(handleResize);
window.addEventListener("resize", handleResize);
window.addEventListener("scroll", handleResize, true);

if (ref.current) {
handleResize();
Expand All @@ -22,6 +23,7 @@ export function useElementBoundingRect(ref: React.RefObject<HTMLElement>): DOMRe
return () => {
resizeObserver.disconnect();
window.removeEventListener("resize", handleResize);
window.removeEventListener("scroll", handleResize, true);
};
}, [ref]);

Expand Down

0 comments on commit c9b9684

Please sign in to comment.