-
Notifications
You must be signed in to change notification settings - Fork 843
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
feat(tabs): traverse tabs with arrow keys #8116
feat(tabs): traverse tabs with arrow keys #8116
Conversation
fa2af92
to
e4511ae
Compare
c89bb30
to
bb63b1c
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.
Can we add a Cypress test checking that this still works if consumers completely change their tabs dynamically? Or what happens if they dynamically disable some tabs?
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.
@cee-chen that's a very good idea! I didn't even think of a dynamic tab use case. Could you share an example from Kibana? Or maybe you have an idea of what that test could look like?
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 been a use case reported in a bug by our users, primarily for EuiTabbedContent
:
- [EuiTabbedContent] TypeError: Cannot read property 'content' of undefined #7350
- [EuiTabbedContent] Fix error when updated with a completely new
tabs
prop #7713
Making it an EuiTabbedContent
Cypress test (or Jest test, whatever's easier) where the component gets updated with new tabs
probably makes the most sense.
a170f27
to
63b23a6
Compare
63b23a6
to
a0cb507
Compare
Apologies it took me so long to get back to this PR Weronika! Your changes look terrific. Just to recap, here's what's remaining
Once the above is in, I think this is good to merge! |
704a2e8
to
c10696e
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.
Changes LGTM. I have an optional extra regression test request around tabbing past disabled tabs, but I don't want it to block this PR as it's working now :)
id: 'world', | ||
name: 'New tab 2', | ||
content: <p>World</p>, | ||
}, |
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.
Optional - can we add a 3rd tab and disable the 2nd one to confirm that arrow keying past disabled tabs works as expected? I mention this because this UX was broken before we added the :not([disabled])
selector as part of the code review, so I'd like to make sure it doesn't regress in the future!
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.
@cee-chen absolutely we can add it, thank you for the suggestion 🙌🏻
What would you say about the inert case? I don't see the tabs consuming inert
prop and setting inert
on a parent doesn't make sense for testing whether an inert element is skipped.
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.
Yeah I'm fine skipping explicit inert
testing, disabled was the main one I wanted to ensure had a test!
refactor(tabs): simplify looping through tabs logic
c10696e
to
62f2781
Compare
Preview staging links for this PR:
|
💚 Build Succeeded
History
|
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.
Thanks for adding the extra disabled test Weronika!! This looks and works great!
Summary
Both the WCAG and MDN specifications for tabs specify that they should be within a tab group and traversed via arrow keys.
Screen.Recording.2024-11-05.at.12.41.35.mov
I've noticed there are 2 ways the tabs are used:
tabpanel
; EuiTabs and EuiTab accessible from the same level),I decided to put the logic inside EuiTabs as its the common point between the 2 use cases and it makes sense for that wrapper to traverse the nodes within and manipulate the DOM (as opposed to traversing them inside EuiTab from the
parentElement
or handling in EuiTabbedContent).closes #8005
QA
I tested the changes in the Storybook, the docs and against Kibana (the provided use case: Main Menu > Management > Dev Tools) with VoiceOver.
General checklist
Checked in both light and dark modesEdge, and FirefoxAdded documentationProps have proper autodocs (using@default
if default values are missing) and playground togglesChecked Code Sandbox works for any docs examplesUpdated visual regression tests(not applicable)If applicable, added the breaking change issue label (and filled out the breaking change checklist)If applicable, file an issue to update EUI's Figma library with any corresponding UI changes. (This is an internal repo, if you are external to Elastic, ask a maintainer to submit this request)