-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(stepper): throw when out-of-bounds value is assigned to selectedIndex #9127
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
Conversation
Shouldn't we actually throw an error in this case? That way the user knows what they're doing wrong rather than trying to track down strange behavior. Maybe just throw a custom error instead of whatever is thrown now that explains better? |
That also makes sense, but I went with this approach, because it’s consistent with what we do in the tabs. |
@andrewseguin do you think the tabs behavior should change or this should match what tabs currently does? |
As a developer I'd probably want to see an error rather than the component fixing itself. I think though that this fix is in favor of the end-user who runs across an edge case where the developer made a mistake. I vote for changing both tabs and this to throw an error and be clear to the developer that their logic isn't right |
797366a
to
38db85b
Compare
Switched it to throw an error @mmalerba @andrewseguin. |
…ndex Throws better error when an out-of-bounds value is assigned to the `selectedIndex`.
38db85b
to
ef9c8f4
Compare
@andrewseguin I'm looking at adding similar changes to the tabs and there's a case that we didn't consider: the tabs/steps could be added asynchronously in which case the consumer starts getting into race conditions instead of having the component default to zero. |
Hmm that's an interesting point, so we expect that the selected index stays as out of bounds in case the steps/tabs are updated later? |
No, it's more like we set it to zero when it's out of bounds, rather than throw an error, because we can't know whether any new elements are going to come in. @andrewseguin |
In that case, should we expect the developer to still be accurate and change the |
I suppose, but that ends up being a lot more inconvenient. |
Probably needs more discussion but this is fine if you want this behavior for now |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Throws better error when an out-of-bounds value is assigned to the
selectedIndex
.