Skip to content

Commit

Permalink
#184 Add open/close timeout to improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
dawsonbooth committed Aug 12, 2021
1 parent 11e7cd4 commit 2c9c7a0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,18 +365,20 @@ const Dropdown = ({

setIsOpen(true);

const optionsContainer = optionsContainerInternalRef.current;
if (optionsContainer) {
if (isVirtual) {
const virtuosoContainer = optionsContainer.firstElementChild;
const virtuosoScroller = virtuosoContainer?.firstElementChild;
if (virtuosoScroller && virtuosoScroller.clientHeight < optionsContainer.clientHeight) {
setIsOverflowing(false);
window.setTimeout(() => {
const optionsContainer = optionsContainerInternalRef.current;
if (optionsContainer) {
if (isVirtual) {
const virtuosoContainer = optionsContainer.firstElementChild;
const virtuosoScroller = virtuosoContainer?.firstElementChild;
if (virtuosoScroller && virtuosoScroller.clientHeight < optionsContainer.clientHeight) {
setIsOverflowing(false);
}
} else if (optionsContainer.scrollHeight > optionsContainer.clientHeight) {
setIsOverflowing(true);
}
} else if (optionsContainer.scrollHeight > optionsContainer.clientHeight) {
setIsOverflowing(true);
}
}
}, 0);

if (onFocus) {
onFocus();
Expand Down

0 comments on commit 2c9c7a0

Please sign in to comment.