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

Make sure data-disabled is available on virtualized options #3128

Merged
merged 4 commits into from
Apr 24, 2024

Conversation

thecrypticace
Copy link
Contributor

When using a combobox disabled options get a data-disabled attribute that can be used for styling. However, when the combobox was virtualized we were not. This happened because we were only looking at the disabled prop on the option itself but a virtual combobox uses a disabled function in the virtual options to determine whether or not an option is enabled.

This fixes that 👍

@RobinMalfait you have an idea on how this should be tested?

Copy link

vercel bot commented Apr 24, 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 Apr 24, 2024 1:29pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2024 1:29pm

@RobinMalfait
Copy link
Member

@thecrypticace if I'm not mistaken we run all tests for the Combobox against a virtual and non-virtual version. So if you add a test where you explicitly test that data-disabled is present then that should cover this. Undoing your change should then result in a failing test.

@thecrypticace
Copy link
Contributor Author

We run all the "interaction" tests but not rendering tests. But this is simple enough to add a test for — will do!

@thecrypticace
Copy link
Contributor Author

Test added

This way we only have to calculate it once and we can re-use that
information throughout the component. If the `value` changes of the
option, then the component has to re-render anyway which will re-compute
the `disabled` state.
@thecrypticace thecrypticace merged commit 166e862 into main Apr 24, 2024
8 checks passed
@thecrypticace thecrypticace deleted the fix/data-disabled-on-virtual-options branch April 24, 2024 13:32
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