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

DropdownMenu onOpenChange fires twice when forceMount is used #2553

Closed
MetaBenji opened this issue Nov 30, 2023 · 1 comment
Closed

DropdownMenu onOpenChange fires twice when forceMount is used #2553

MetaBenji opened this issue Nov 30, 2023 · 1 comment

Comments

@MetaBenji
Copy link

Bug report

Current Behavior

I'm trying to keep the content of the dropdown menu mounted in the DOM even when its closed by using forceMount, onOpenChange and display: none. Whenever I click on the trigger button, it runs the onOpenChange function twice, toggling it back to its original state.

Expected behavior

The onOpenChange function only runs once.

Reproducible example

CodeSandbox Link

Suggested solution

Additional context

Your environment

Software Name(s) Version
Radix Package(s)
React n/a
Browser
Assistive tech
Node n/a
npm/yarn
Operating System
@benoitgrelard
Copy link
Contributor

I'm trying to keep the content of the dropdown menu mounted in the DOM even when its closed by using forceMount

Trying to do this using will result in all sorts of other issues as this is not the intended use for forceMount, and other things like focus trapping and other listeners would still be active if you kept it rendered. forceMount is here for the purpose of JS-based animations.

There could be an argument made for SEO reasons, that's what we are discussing over in #1155, I invite you to read up there.

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

No branches or pull requests

2 participants