-
Notifications
You must be signed in to change notification settings - Fork 26
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
Refactor shadowdom #77
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This refactors tab container to make extensive use of the shadowdom. This allows us to be smarter about a few things: - The `role=tablist` can be omitted, and the component will simply provide it. This makes it easier to author a tablist that is accessible because the only required markup is some `<button role=tab>` with some `<button role=panel>`. - The `role=panel` gets manually assigned which means it's far harder to show two tab-panels at once. With the current implementation it can sometimes get into states where more than the current panel is visible. With assignedSlot this is close to impossible. - Much of the required aria markup can be hidden away in the shadowdom which means consumers are less able to influence it, allowing us to keep tighter control of it.
If the root `<tab-container>` element is given aria-label or aria-description this often results in a slightly weird accessibility tree because the root container is a generic role. The label/description _should_ be on the tablist role. This makes that happen by detecting the aria-* attributes on tablist and moving them appropriately.
This enables `<tab-container vertical>` for a much more ergonomic way to create & style tab containers. This also automatically handles the necessary aria markup for the tablist.
The current `<tab-container>` is generic role, which is fine except for it makes for a messier AT than necessary. The `<tab-container>` itself _is_ a presentational element (the real AT relevant elements are the tablist, tabs, and panels), so this change makes that explicit by setting role=presentation to the tab-container.
By default tabListSlot is `display:contents` which can cause a couple of issues: 1. Some browsers don't expose role information for elements that are display:contents, and so this makes an inaccessible component. 2. Depending on how the tabs are styled, they can end up in weird orientations due to the tablist having no layout. Making it have a layout with display:block fixes this.
Prior to using shadowdom, the tab container allowed for elements interspersed between the tabs and panels. This re-introduces that using Slots for more precise markup. This works well wrt elements that are before or after tabs given that a tablist can only have tab role children.
owenniblock
approved these changes
Feb 16, 2024
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.
Love it! A few non-blocking thoughts.
Also, thanks for breaking up the PR so nicely! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This refactors tab container to make extensive use of the shadowdom.
Each commit describes the benefits and features of this refactor so it's best to read each commit.