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

Implement nullable mode on Combobox in single value mode #1295

Merged
merged 4 commits into from
Mar 31, 2022

Conversation

RobinMalfait
Copy link
Member

This PR adds a nullable prop to the Combobox component which is defaulted to false.

If this prop is provided, and you clear the text in the input value, then the Combobox option will
be cleared as well. We will do that by calling your onChange with null in React, or setting the
v-model to null in Vue.

This feature allows you to "clear" a Combobox value once it is set, whereas otherwise this isn't
possible unless you provide a custom "Unset" Combobox.Option or a button to reset the value.

If you pass a `nullable` prop to the Combobox, then it's possible to
unset the Combobox value by setting it to `null`.
This is triggered by removing all text from the input which will reset
the value itself as well.
@vercel
Copy link

vercel bot commented Mar 31, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

headlessui-vue – ./packages/playground-vue

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-vue/4rKf6JvJeSSiSp1AKfNnXMMC5Dbp
✅ Preview: https://headlessui-vue-git-nullable-combobox-tailwindlabs.vercel.app

headlessui-react – ./packages/playground-react

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-react/Egaju6ZCSZwBYUZH2v2N9vFJQNif
✅ Preview: https://headlessui-react-git-nullable-combobox-tailwindlabs.vercel.app

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.

1 participant