-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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 MatTabNav as ARIA tabs with a new MatTabNavPanel component and [tabPanel] input. #24062
Conversation
@@ -151,6 +183,7 @@ export abstract class _MatTabNavBase | |||
templateUrl: 'tab-nav-bar.html', | |||
styleUrls: ['tab-nav-bar.css'], | |||
host: { | |||
'[attr.role]': 'tabPanel ? "tablist" : null', |
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.
@crisbeto This - as well as some of the aria-*
attribute host bindings changes below - are breaking changes. For example, if a consumer has added role="<something>"
to this element, then after this PR is submitted, this host binding will override their specified role
and set it to null
(as no tabPanel
will have been provided). We can avoid this breaking change by modifying this logic to check to see if a role
has been provided, and if so, use that. For example:
'[attr.role]': 'existingRole || (tabPanel ? "tablist" : null)'
We'd want to do the same to the other added aria-*
host bindings. WDYT?
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 don't think that this is a breaking change since our host bindings are implementation details and they won't break people's builds. I also suspect that it's rare for people to actually set these aria-
attributes correctly. If we do get issue reports about it, it'll be easy to follow up with a fix.
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.
Okay.
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.
Updated the PR per our conversation to fallback to the existing ARIA host attributes if no tabPanel
is provided, as opposed to removing those attributes with a null
attribute binding. This makes this PR now truly 100% opt-in & backwards compatible. Consumer code should not change if tabPanel
isn't provided. This makes it much easier to land internally.
After this PR is merged in, I'll:
- Migrate the internal instances of consumers overriding ARIA host attributes to the new
tabPanel
input & associated component. - Remove the code in this PR that "falls back to the existing ARIA host attributes if no
tabPanel
is provided" (as it calls the DOM directly and not something we want in the component long-term). - Migrate the remaining internal consumer instances onto the new
tabPanel
input & associated component. - Remove the code in this PR that falls back to the ARIA link / navigation landmark pattern if no
tabPanel
is provded.
Re-opening to give @crisbeto a chance to ack this.
6dc9473
to
5163cd8
Compare
src/material-experimental/mdc-tabs/testing/tab-nav-panel-harness.ts
Outdated
Show resolved
Hide resolved
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.
LGTM, the last comment isn't a blocker.
src/components-examples/material/tabs/tab-nav-bar-with-panel/tab-nav-bar-with-panel-example.ts
Outdated
Show resolved
Hide resolved
by introducing a new tabpanel component.
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.
Read through the summary and did a quick pass on the code, overall LGTM.
…rn (angular#24062) by introducing a new tabpanel component.
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. |
Fixes #23706.
MatTabNavPanel
component that is intended to be used withMatTabNav
.MatTabNavPanel
renders thetabpanel
,MatTabNav
renders thetablist
.[tabPanel]
input toMatTabNav
that accepts aMatTabNavPanel
. AllowsMatTabNav
to make changes toMatTabNavPanel
(i.e.aria-labelledby
).[tabPanel]
is provided,MatTabNav
acts as an ARIA tabs. Otherwise, it continues to act as links within a navigation landmark (no change from status quo).