Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DismissableLayer] After clicking on element that stops propagation, 2 outside clicks are required to close the layer #2782

Open
jaknas opened this issue Mar 15, 2024 · 2 comments

Comments

@jaknas
Copy link

jaknas commented Mar 15, 2024

Bug report

Current Behavior

I'm using a Radix Popover that internally uses DismissableLayer. Inside of that Popover I have buttons that call event.stopPropagation() in their onPointerDown handler. After clicking on such a button and trying to exit the Popover relying on onPointerDownOutside, it requires 2 clicks instead of 1.

Expected behavior

I'd expect the Popover to close using a single click outside regardless if my content inside is stopping propagation.

Reproducible example

CodeSandbox

Suggested solution

The issue seems to come from the fact that after the 1st click the isPointerInsideReactTreeRef ref is being set to true in the onPointerDownCapture handler. During the same event, we should expect the handlePointerDown function to be called and set the ref to false. This ultimately does not happen because the event does not bubble up to the pointerdown listener.

I don't really have an idea how this could be fixed.

Additional context

For context, I discovered this when trying to combine Radix Popover with React-Aria Calendar inside. Related: adobe/react-spectrum#5799 (comment)

Your environment

Software Name(s) Version
Radix Package(s) popover latest
React n/a latest
Browser Chrome 122
Assistive tech
Node n/a
npm/yarn
Operating System MacOS Sonoma 14.4
@ht-lovrozagar
Copy link

Same happens if using react-aria button inside a Popover.

@theMosaad
Copy link

Same happens if using react-aria button inside a Popover.

Had that issue for years and ended up moving everything to react-aria-components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants