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

fix(menu): keyboard controls not respecting DOM order when items are added at a later point #11720

Merged
merged 1 commit into from
Jul 9, 2019

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Jun 8, 2018

A while ago we reworked the menu not to pick up the items of other child menus. As a result, we had to use a custom way of registering and de-registering the menu items, however that method ends up adding any newly-created items to the end of the item list. This will throw off the keyboard navigation if an item is inserted in the beginning or the middle of the list. With these changes we switch to picking up the items using ContentChildren and filtering out all of the indirect descendants.

Fixes #11652.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 8, 2018
@@ -238,19 +238,27 @@ export class MatMenu implements AfterContentInit, MatMenuPanel<MatMenuItem>, OnI
}

ngAfterContentInit() {
this._keyManager = new FocusKeyManager<MatMenuItem>(this._items).withWrap().withTypeAhead();
this._allItems.changes
Copy link
Member

Choose a reason for hiding this comment

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

Add comment here that explains what you're doing (collecting direct descendants) and why they're needed? Might also be good to break this out into its own method like _updateDirectDescendants

@crisbeto crisbeto force-pushed the 11652/menu-children-order branch from fcfef34 to 7b64465 Compare June 29, 2018 16:14
@crisbeto
Copy link
Member Author

Addressed the feedback.

@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label Jun 29, 2018
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

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jun 29, 2018
@jelbourn
Copy link
Member

@crisbeto github shows this PR as having no conflicts, but our presubmit script thinks it does. Could you rebase it?

@crisbeto crisbeto force-pushed the 11652/menu-children-order branch from 7b64465 to 1276018 Compare August 26, 2018 16:49
@crisbeto
Copy link
Member Author

Done.

@crisbeto crisbeto added the G This is is related to a Google internal issue label Sep 10, 2018
@ngbot
Copy link

ngbot bot commented Nov 3, 2018

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@crisbeto crisbeto force-pushed the 11652/menu-children-order branch from 1276018 to 03b01ec Compare November 8, 2018 10:03
@crisbeto crisbeto added the Accessibility This issue is related to accessibility (a11y) label Nov 8, 2018

/**
* @deprecated To be removed.
* @deletion-target 8.0.0
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @deletion-target 8.0.0
* @breaking-change 8.0.0

There are two lint failures for removeItem and addItem

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed.

@crisbeto crisbeto force-pushed the 11652/menu-children-order branch from 03b01ec to 91e67fc Compare November 8, 2018 22:34
@dmk1111
Copy link

dmk1111 commented Dec 12, 2018

Hi @devversion @jelbourn @crisbeto !
Are there any updates on this? We faced this issue with dynamic menu items, so it would be nice to know when it will be released approximately.

Thanks!

@crisbeto crisbeto force-pushed the 11652/menu-children-order branch from 91e67fc to 2fd886a Compare December 15, 2018 16:48
@scriby
Copy link
Collaborator

scriby commented Jan 16, 2019

I hit this bug today (working on a Google product at Google)

@crisbeto crisbeto force-pushed the 11652/menu-children-order branch 2 times, most recently from 7cdd32a to 2eb0545 Compare January 16, 2019 20:37
@crisbeto crisbeto force-pushed the 11652/menu-children-order branch 2 times, most recently from 9f5ef98 to 410fc9d Compare February 22, 2019 15:52
@crisbeto crisbeto added the P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful label Feb 26, 2019
@jelbourn jelbourn added the P2 The issue is important to a large percentage of users, with a workaround label Mar 6, 2019
@jelbourn jelbourn removed the P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful label Mar 6, 2019
@mmalerba mmalerba added the blocked This issue is blocked by some external factor, such as a prerequisite PR label Mar 13, 2019
@mmalerba
Copy link
Contributor

there are some internal apps that need to be cleaned up before this can be merged

@andrewseguin
Copy link
Contributor

@crisbeto Can you check out the test failures? I'm working with a team internally to fix a test so we can get this merged

…added at a later point

A while ago we reworked the menu not to pick up the items of other child menus. As a result, we had to use a custom way of registering and de-registering the menu items, however that method ends up adding any newly-created items to the end of the item list. This will throw off the keyboard navigation if an item is inserted in the beginning or the middle of the list. With these changes we switch to picking up the items using `ContentChildren` and filtering out all of the indirect descendants.

Fixes angular#11652.
@crisbeto crisbeto force-pushed the 11652/menu-children-order branch from e431613 to 243bd2f Compare July 8, 2019 18:41
@crisbeto
Copy link
Member Author

crisbeto commented Jul 8, 2019

Fixed @andrewseguin. Looks like there were some breaking changes in 8.0 I hadn't accounted for.

@jelbourn jelbourn removed the blocked This issue is blocked by some external factor, such as a prerequisite PR label Jul 9, 2019
@jelbourn jelbourn merged commit 49e8c59 into angular:master Jul 9, 2019
jelbourn added a commit to jelbourn/components that referenced this pull request Jul 11, 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
Accessibility This issue is related to accessibility (a11y) action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need keyboard navigation order to match visual order of menu items
8 participants