-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Controlled mode for Tabs component in React does not work #1509
Comments
Hey! Thank you for your bug report! Please make sure that you save all the files in your CodeSandbox before sharing. It's currently empty: That said, here is a CodeSandbox that demonstrates that you can change the tab (use the previous & next buttons): https://codesandbox.io/s/patient-breeze-86frfd?file=/src/App.js |
Hey @RobinMalfait 👋 Thanks a bunch for such a helpful library 🎉 I think the problem OP posted was that we can still change the tab via Here is the repro sandbox: One use case I think this would help solve is when we need to validate something before moving to another tab (e.g: show a notice if there are unsaved changes on the current tab) But maybe I miss something in the doc. Could you help me take a look ❓ |
I'm having the same issue. The |
For those wanting a not-very-pretty workaround (effective with clicking the tabs, though not keyboard nav events), here's what I figured out:
If anyone else has a nicer solution than this, please share. 🙂 |
Hey! Thank you for your bug report! @ptmdmusique your reproduction helped. This should be fixed by #1680, and will be available in the next release. I also updated the CodeSandbox with the latest insiders version to see the fix in action: https://codesandbox.io/s/headless-ui-tabs-forked-h8h0lp?file=/src/App.js You can already try it using:
|
This feature is working great in the insiders version! Is there any PR or issue that I can subscribe to in order to stay updated when this has been released in a new update? :) |
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v1.6.3
What browser are you using?
Chrome
Reproduction URL
https://codesandbox.io/s/cool-https-tsn49q
Describe your issue
Controlled mode for Tabs component in React does not work, no matter if the state is inside of the component or outside, even if I would put
selectedIndex={0}
I still can change the tab.The text was updated successfully, but these errors were encountered: