-
-
Notifications
You must be signed in to change notification settings - Fork 447
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
enable controlled component behavior #80
Conversation
if you pass a `selectedIndex` prop, then that tab will be selected, no matter what. it doesn't change automatically from user interaction. to change in response to interaction, have the parent pass an `onSelect` handler that updates the `selectedIndex` prop.
note that the CI failures here are due to a rackt-cli issue, ref'd by #79 |
previously, in order for focus management to work, we assumed the parent would rerender the tabs component when its onSelect handler was invoked. that was probably a pretty safe assumption, but we no longer rely on it. also made it more explicit (and enforced) that `selectedIndex` and `onSelect` come as a pair. and improved test coverage around this stuff.
Thanks for the contribution, I'm a little bit worried that this is too much magic with having to set To make it more obvious to users what is happening I thought of splitting Another approach would be to have a prop like What are your thoughts on this? Sorry that it took so long long to look through the PR. |
TL;DR: great idea, love the added API clarity; I say let's really mirror controlled component behaviour and do proper warnings and similar prop naming conventions My 2¢: I like this a lot, I think adding this would add clarity to For naming, I would suggest going with Similarly mirroring React, I would suggest forcing users to choose between using
BTW I don't think that warning is clear enough to people who don't know (yet) what a controlled component is, which would be relevant here as well, so I'd at least mention the specific attributes that are causing it to be thrown. Another thing to consider is how React handles passing
Not sure if I'd go for having a @mziwisky if you'd like some help on this, give me a shout. 😃 |
Thanks for the replies, guys. I'm +1 on changing this interface to closer reflect that of builtin React components. Considering your feedback, here's my summary of the behavioral changes I think this PR needs:
Is that the right set of changes? Am I missing anything? I do prefer I don't know when I'd be able to get around to this. @joepvl if you've got the time and desire to make it happen, I'd gladly leave it in your hands and provide code reviews if you'd like. |
Just popping in to let you know I'm not ignoring this & haven't forgotten about it. I just have little time either atm but am definitely up for picking it up when that changes. Regrettably, not sure how long that will take, it may be a few weeks. |
if you pass a
selectedIndex
prop, then that tab will be selected, nomatter what. it doesn't change automatically from user interaction. to
change in response to interaction, have the parent pass an
onSelect
handler that updates the
selectedIndex
prop.fixes #74
definitely warrants a major version bump