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 initial anchor="selection" state #3324

Merged
merged 2 commits into from
Jun 25, 2024
Merged

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Jun 25, 2024

This PR fixes a bug where using the anchor="selection" results in an incorrectly positioned anchor panel.

This happened because we computed the index too late and didn't re-render to fix up the UI.

To solve this, this PR computes it based on actual state instead of DOM nodes.

We will also compute the selected option based on the frozen state. This will prevent UI glitches while closing the Listbox.

Copy link

vercel bot commented Jun 25, 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 Jun 25, 2024 9:53am
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 25, 2024 9:53am

Instead of relying on the DOM directly, we can compute the
`selectedOptionIndex` and rely on the data directly.

We will also freeze the value while closing to prevent UI changes.
@RobinMalfait RobinMalfait merged commit ff41b27 into main Jun 25, 2024
8 checks passed
@RobinMalfait RobinMalfait deleted the fix/anchor-selection branch June 25, 2024 13:16
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

Successfully merging this pull request may close these issues.

2 participants