Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/eui/changelogs/upcoming/7760.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**Bug fixes**

- Restored a removed `setTimeout` in `EuiInputPopover` to reduce flaky Cypress failures

13 changes: 9 additions & 4 deletions packages/eui/src/components/popover/input_popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,20 @@ export const EuiInputPopover: FunctionComponent<EuiInputPopoverProps> = ({
closePopover();
};

window.addEventListener('scroll', closePopoverOnScroll, {
passive: true, // for better performance as we won't call preventDefault
capture: true, // scroll events don't bubble, they must be captured instead
});
// Kibana Cypress tests trigger a scroll event in many common situations when the options list div is appended
// to the DOM; in testing it was always within 100ms, but setting a timeout here for 500ms to be safe
const timeoutId = setTimeout(() => {
window.addEventListener('scroll', closePopoverOnScroll, {
passive: true, // for better performance as we won't call preventDefault
capture: true, // scroll events don't bubble, they must be captured instead
});
}, 500);

return () => {
window.removeEventListener('scroll', closePopoverOnScroll, {
capture: true,
});
clearTimeout(timeoutId);
};
}
}, [closeOnScroll, closePopover, panelEl, inputEl]);
Expand Down