-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
[Tabs] Fix keyboard navigation involving disabled Tabs #1449
Conversation
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
bd7dfb7
to
7dbdef8
Compare
This comment was marked as outdated.
This comment was marked as outdated.
7dbdef8
to
05c214f
Compare
9ddf851
to
2c50af8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I haven't found any issues in behavior.
@@ -94,6 +94,7 @@ const TabsList = React.forwardRef(function TabsList( | |||
onHighlightedIndexChange={setHighlightedTabIndex} | |||
onMapChange={setTabMap} | |||
render={renderElement()} | |||
disabledIndices={[]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not recreate the array on each render.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
@@ -58,11 +58,15 @@ function useTabsTab(parameters: useTabsTab.Parameters): useTabsTab.ReturnValue { | |||
return valueParam === selectedTabValue; | |||
}, [index, selectedTabValue, valueParam]); | |||
|
|||
// when activateOnFocus is `true`, ensure the active item in Composite's roving | |||
// focus group matches the selected Tab | |||
const selectedValueSyncedWithHighlightedTabIndexRef = React.useRef(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a mouthful :)
But too long is much better than too short, so let's leave it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is all within a few lines so I shortened it by 12 chars 😅
isSelectionSyncedWithHighlightRef
Fixes #1442
Before: https://codesandbox.io/p/sandbox/tender-bassi-w74kv9
After: https://codesandbox.io/p/devbox/restless-framework-g3j43t?file=%2Fsrc%2FApp.tsx
Tabs are intentionally focusable when disabled, so it should be possible to move focus to disabled Tabs using the arrow keys. The disabled state should only disable tab activation.