-
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
feat(material/tabs): Throw error in MDC tabs if [tabPanel] input is not provided #24517
Conversation
@@ -185,5 +185,15 @@ export const config = { | |||
'should set the old snack bar animation state to complete and the new snack bar ' + | |||
'animation state to visible on entry of new snack bar', | |||
], | |||
'mdc-tabs': [ | |||
// These tests are excluded because they are verifying behavior that is not supported in MDC. | |||
'should have no explicit roles', |
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.
Should the feature or missing tests be ported over? The MDC tabs should have feature parity with the existing ones.
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 PR changes MDC tabs to not have feature parity with the existing tabs. In the existing tabs, the [tabPanel]
input is optional. If it isn't provided, then the tabs fall back to default link/navigation behavior to avoid breaking existing instances in g3 that are impossible for me to migrate to use the [tabPanel]
. In the new MDC tabs, we throw an error if the [tabPanel]
input isn't provided. Thus, as users migrate from existing to MDC, if they're not already using the [tabPanel]
input, they'll need to do so.
Given the [tabPanel]
input is enforced in MDC tabs, we don't need to verify/test any of the link/navigation fallback behavior. That's why I explicitly didn't port over these tests.
@@ -114,6 +115,12 @@ export class MatTabNav extends _MatTabNavBase implements AfterContentInit { | |||
this._inkBar = new MatInkBar(this._items); | |||
super.ngAfterContentInit(); | |||
} | |||
|
|||
override ngAfterViewInit() { | |||
if (!this.tabPanel && (typeof ngDevMode === 'undefined' || ngDevMode)) { |
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.
nit: this won't catch the case where it starts off with a panel and it gets removed afterwards. Not sure if we need to worry about 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.
I think that's an exceptional case that we don't need to warn against, but I'm happy to move the check to either a setter or ngOnChanges
if we feel otherwise.
…ot provided (angular#24517) * feat(material/tabs): Throw error in MDC tabs if [tabPanel] is not provided. * feat(material/tabs): Exclude some tests from MDC * feat(material/tabs): Add tab panel to kitchen sinks
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. |
This PR updates MDC nav tabs to throw an error if the
[tabPanel]
input is not provided. Note that no such logic is added to the non-MDC tabs.Additionally: