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

Fix crash when using as={Fragment} on MenuButton, ListboxButton, DisclosureButton or Button components #3478

Merged
merged 6 commits into from
Sep 12, 2024

Conversation

RobinMalfait
Copy link
Member

This PR fixes an issue where a maximum update depth exceeded error was thrown when using as={Fragment} on button related components.

The issue here is that the ref on a element would re-fire every render if the a function was used and the function is a new function (aka not a stable function).

This resulted in the ref being called with the DOM element, then null, then the DOM element, then null, and so on.

To solve this, we have to make sure that the ref is always a stable reference.

Fixes: #3476
Fixes: #3439

Copy link

vercel bot commented Sep 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 12, 2024 9:28am
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 12, 2024 9:28am

@RobinMalfait RobinMalfait changed the title Fix crash when using as={Fragment} on MenuButton, ListboxButton, DisclosureButton and Button components Fix crash when using as={Fragment} on MenuButton, ListboxButton, DisclosureButton or Button components Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants