Accept tabIndex in the useFocusable hook#1391
Conversation
d6d03cd to
3424028
Compare
3424028 to
01bfa24
Compare
|
Plus missing tests?! 🤩 Thankyou |
| excludeFromTabOrder?: boolean | ||
| excludeFromTabOrder?: boolean, | ||
| /** A tabIndex to return. */ | ||
| tabIndex?: number |
There was a problem hiding this comment.
This shows that we'll have 2 competing props - excludeFromTabOrder and tabIndex which both "control" the returned tabIndex. I would say this is not ideal - maybe excludeFromTabOrder should be deprecated in the future?
| { | ||
| ...interactions, | ||
| tabIndex: props.excludeFromTabOrder && !props.isDisabled ? -1 : undefined | ||
| tabIndex: props.tabIndex ?? (props.excludeFromTabOrder && !props.isDisabled ? -1 : undefined) |
There was a problem hiding this comment.
q: what should happen for {tabIndex: 0, isDisabled: true}?
|
We'd like to keep Most of the the components using
|
That doesn't quite avoid the problem though and you also lose validation opportunity the way it's handled right now.
That's understandable - but if you plan to proceed with this PR then this creates a tiny conflict between
Maybe a good opportunity to add dev-only validation for this in the
The slight problem I have with this is that for a consumer it's not obvious that this is different from other props in other hooks that "could just be applied to the element directly".
That would definitely be an improvement 👍 I probably don't mind this whole case that much as it feels sort of special - but you have a much broader context to assess if that's actually the case. Docs + validation would be nice though - I believe that this (especially validation) would improve the DX greatly. |
|
@devongovett any further thoughts on this PR? |
8cb1a5d to
3013156
Compare
a79adcf to
3013156
Compare
Closes #1384 , cc @ktabors
✅ Pull Request Checklist:
📝 Test Instructions:
yarn test