Skip to content

feat(tabs): support pagination in nav bar #16055

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

Merged
merged 1 commit into from
Jun 26, 2019

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented May 18, 2019

Adds support for pagination to mat-tab-nav-bar by moving some code around so that it can be reused from the mat-tab-group.

Fixes #2177.

Some outstanding questions:

  • How should we deal with the tabindex in mat-tab-nav-bar? Currently all enabled links have tabindex="0", but now that we support keyboard navigation, we could switch to the same approach as mat-tab-group.
  • With these changes the tab header styles are imported in the Sass of both mat-tab-nav-bar and mat-tab-header. This means that these styles will be included twice and I don't think there's a nice way around it. We can include the same file through styleUrls, however our style inlining won't de-duplicate the styles in that case either.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 18, 2019
@crisbeto crisbeto force-pushed the tab-nav-bar-pagination branch 3 times, most recently from c3e79c0 to 603d68a Compare May 18, 2019 13:15
@crisbeto crisbeto added the target: minor This PR is targeted for the next minor release label May 18, 2019
@crisbeto crisbeto marked this pull request as ready for review May 18, 2019 13:27
@crisbeto crisbeto requested a review from andrewseguin as a code owner May 18, 2019 13:27
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall

super(elementRef, changeDetectorRef, viewportRuler, dir, ngZone, platform);
}

protected _itemSelected() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be optional in the abstract class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently optional abstract methods aren't supported by TS. I can mark it as optional, but it still requires it to be defined on the sub-class.

Copy link
Contributor

@andrewseguin andrewseguin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one request: can you add an example for the nav so that it either starts with many labels or a way to dynamically add/remove labels? Would be nice to have an example that shows pagination easily.

@crisbeto crisbeto force-pushed the tab-nav-bar-pagination branch from 603d68a to 5570882 Compare May 22, 2019 21:02
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label May 22, 2019
@crisbeto
Copy link
Member Author

Reworked based on the feedback.

@andrewseguin andrewseguin added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label May 30, 2019
@andrewseguin
Copy link
Contributor

Looks like we've got an issue when the nav bar's active link is not the first link. We are calling updateActiveLink a little too early and so the ink bar does not position itself at the right time. Instead, when it is called, this._items is not yet populated.

@andrewseguin
Copy link
Contributor

You can replicate the issue in our demo app by setting the active link to the second or third link rather than defaulting to the first. You'll see the ink bar positioned under the first link.

@crisbeto crisbeto force-pushed the tab-nav-bar-pagination branch from 5570882 to 9f1f03a Compare June 2, 2019 08:00
@crisbeto
Copy link
Member Author

crisbeto commented Jun 2, 2019

Thank you @andrewseguin. I've updated it to account for updateActiveLink being called too early.

@jelbourn jelbourn added P2 The issue is important to a large percentage of users, with a workaround and removed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Jun 7, 2019
@mmalerba
Copy link
Contributor

A couple tests seem to be failing a11y checks with the following error:

{
  "description": "Ensures elements with an ARIA role that require child roles contain them",
  "help": "Certain ARIA roles must contain particular children",
  "helpUrl": "https://dequeuniversity.com/rules/axe/2.5/aria-required-children?application=axeAPI",
  "nodes": [
    {
      "html": "<div class=\"mat-tab-list\" role=\"tablist\" style=\"transform: translateX(0px);\">"
    }
  ]
}

@crisbeto crisbeto force-pushed the tab-nav-bar-pagination branch from 9f1f03a to 4679a72 Compare June 11, 2019 19:09
@crisbeto
Copy link
Member Author

Fixed @mmalerba. Looks like a copied a little bit too much from the regular tab header template. Also do we have those a11y checks running on the CI somewhere? I had to run the Chrome extension to see the failure.

@mmalerba
Copy link
Contributor

I filed #16271 for setting up axe tests, @josephperrott is going to look into it

@crisbeto crisbeto force-pushed the tab-nav-bar-pagination branch from 4679a72 to d50b051 Compare June 14, 2019 18:31
Adds support for pagination to `mat-tab-nav-bar` by moving some code around so that it can be reused from the `mat-tab-group`.

Fixes angular#2177.
@crisbeto crisbeto force-pushed the tab-nav-bar-pagination branch from d50b051 to 092c7b3 Compare June 14, 2019 19:11
@andrewseguin andrewseguin merged commit aa22368 into angular:master Jun 26, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P2 The issue is important to a large percentage of users, with a workaround target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tabs] Nav bar should paginate labels on overflow
5 participants