Skip to content
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

docs-bug(mat-tab-nav-panel): Documentation implies that [tabPanel] is optional, but must be specified. #26270

Open
yutamago opened this issue Dec 15, 2022 · 5 comments
Labels
area: material.angular.io area: material/tabs docs This issue is related to documentation P4 A relatively minor issue that is not relevant to core functions

Comments

@yutamago
Copy link

Documentation Feedback

The documentation implies that [tabPanel] can be left unprovided by saying "If not provided, then the nav bar follows the ARIA link / navigation landmark pattern".

However, if left unprovided, it will throw an error stating: "A mat-tab-nav-panel must be specified via [tabPanel]".

Affected documentation page

https://material.angular.io/components/tabs/api#MatTabNav

@yutamago yutamago added docs This issue is related to documentation needs triage This issue needs to be triaged by the team labels Dec 15, 2022
@epelc
Copy link
Contributor

epelc commented Dec 24, 2022

Please fix this. We have been using a standalone tab panel for navigation ie footer of our app for years. We use in combination with router links to go between pages when you click or activate a tab.

Looks like just these lines need to be removed.

override ngAfterViewInit() {
if (!this.tabPanel && (typeof ngDevMode === 'undefined' || ngDevMode)) {
throw new Error('A mat-tab-nav-panel must be specified via [tabPanel].');
}
}
}

The rest of the component works with an optional tabPanel.

@wagnermaciel wagnermaciel added P4 A relatively minor issue that is not relevant to core functions area: material/tabs area: material.angular.io and removed needs triage This issue needs to be triaged by the team labels May 3, 2023
@epelc
Copy link
Contributor

epelc commented May 11, 2023

@wagnermaciel would you accept a PR for changes described in my comment?

It's common to use tabs as nav.

@muenchto
Copy link

muenchto commented Jan 5, 2024

I agree with @epelc, these line should be removed to fit the documentation.
Also, more complicated Apps can easily create a situation where the mat-tab-nav-panel is wrapped by some header component. In this case, providing the tabPanel via an Input does not work because of Angular's CD resolution and throws an ExpressionChangedAfterItHasBeenCheckedError. Bug reported in #28379

@EliezerB123
Copy link

Does anyone know of any workaround to force [tabPanel] to be optional?

We don't want to use [tabPanel] style tabs, because it'll cause us a lot of accessibility problems. (For example, the z-index is set to -1 on all tabs, instead of 0. As well, our mat-tab-nav-panel is buried deep in a component, and providing it with a tabPanel that includes the router-outlet is... difficult.)

@tonybaroneee
Copy link
Contributor

tonybaroneee commented Feb 23, 2024

+1 to everything above. @EliezerB123 I believe the workaround here is to simply have an empty mat-tab-nav-panel:

<nav mat-tab-nav-bar [tabPanel]="tabPanel">
    <a mat-tab-link ...>Link 1</a>
    ...
</nav>
<mat-tab-nav-panel #tabPanel></mat-tab-nav-panel>

That will appease the error while not requiring you to change your page structure/rendering behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material.angular.io area: material/tabs docs This issue is related to documentation P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

6 participants