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

Warn when changing Combobox between controlled and uncontrolled #1878

Merged
merged 8 commits into from Oct 10, 2022

Conversation

thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Sep 27, 2022

We currently don't handle changes to/from undefined. However this is okay. If you specify a value of undefined you're saying you want an uncontrolled component. This follows React's own conventions for inputs for example.

We'll warn when changing between a controlled and uncontrolled component as this can be considered an implementation error.

Fixes #1177

@vercel
Copy link

vercel bot commented Sep 27, 2022

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

Name Status Preview Updated
headlessui-react ✅ Ready (Inspect) Visit Preview Oct 10, 2022 at 2:38PM (UTC)
headlessui-vue ✅ Ready (Inspect) Visit Preview Oct 10, 2022 at 2:38PM (UTC)

Copy link
Collaborator

@RobinMalfait RobinMalfait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I think this might already behave as expected if you look at React itself 🤔

https://codesandbox.io/s/sleepy-snow-v4m8eu?file=/src/App.js

packages/@headlessui-react/src/hooks/use-controllable.ts Outdated Show resolved Hide resolved
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.

[React] Combobox.Input does not clear after removing the current value from the combobox.
2 participants