-
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
fix(menu): keyboard controls not respecting DOM order when items are added at a later point #11720
Conversation
src/lib/menu/menu-directive.ts
Outdated
@@ -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 |
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.
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
fcfef34
to
7b64465
Compare
Addressed the feedback. |
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
@crisbeto github shows this PR as having no conflicts, but our presubmit script thinks it does. Could you rebase it? |
7b64465
to
1276018
Compare
Done. |
Hi @crisbeto! This PR has merge conflicts due to recent upstream merges. |
1276018
to
03b01ec
Compare
src/lib/menu/menu-panel.ts
Outdated
|
||
/** | ||
* @deprecated To be removed. | ||
* @deletion-target 8.0.0 |
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.
* @deletion-target 8.0.0 | |
* @breaking-change 8.0.0 |
There are two lint failures for removeItem
and addItem
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.
Thanks, fixed.
03b01ec
to
91e67fc
Compare
Hi @devversion @jelbourn @crisbeto ! Thanks! |
91e67fc
to
2fd886a
Compare
I hit this bug today (working on a Google product at Google) |
7cdd32a
to
2eb0545
Compare
9f5ef98
to
410fc9d
Compare
there are some internal apps that need to be cleaned up before this can be merged |
410fc9d
to
e431613
Compare
@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.
e431613
to
243bd2f
Compare
Fixed @andrewseguin. Looks like there were some breaking changes in 8.0 I hadn't accounted for. |
…ems are added at a later point (angular#11720)" This reverts commit 49e8c59.
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. |
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.