You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That outside press listener should probably be a capturing listener. There are many reasons something might stop propagation. I doubt we are the only instance where this would be problematic for closing the overlay on a click outside.
useInteractOutside({
ref: floatingRef,
isDisabled: !isOpen,
onInteractOutside: useCallback(({ target }) => {
// skips the button reference because its onPress already swaps the open state
if (referenceRef.current?.contains(target)) {
return;
}
setIsOpen(false);
}, [])
});
🐛 Bug Report
I need to globally listen for click events that happen in any component to close a floating element.
🤔 Expected Behavior
This should be called when clicking on any component, including react-aria buttons
😯 Current Behavior
react-aria buttons stop propagation of events, making global listeners not work as expected.
💁 Possible Solution
probably related to #2100 and #2525
🔦 Context
Button
component usinguseButton
from react aria.Here is an example with both
useButton
(from react-aria) anduseFloating
(from floating-ui)https://codesandbox.io/s/use-button-floating-ui-eo3joc?file=/src/App.tsx
The floating menu from the last button ("Show context menu") isn't closing when "React aria-button" is closed
💻 Code Sample
https://codesandbox.io/s/use-button-global-listeners-r6rg6x?file=/src/App.tsx
pointerdown
listener🌍 Your Environment
The text was updated successfully, but these errors were encountered: