Replies: 7 comments 6 replies
|
(spent days trying to figure it out but all I've come up with is it working some of the time until the focus ring stops (although pressing enter still works, but up/down doesn't)) |
|
seems calling .focus only works once? I'm not sure exactly how to fix. |
|
On https://material-web.dev/components/menu/ when I click on "Apricot" (Apple is selected first) and then re-open the menu, Apple does not have the rings. Think there could be a bug? Screen.Recording.2025-06-15.at.14.16.34.mov |
|
I found a really ugly hack for issue 2 but it works: https://gist.github.com/paladox/09d0f67df94630278b542b15cfca5b83 |
|
For issue 1: For issue 2: focus rings should not be visible when using the pointer. They should become visible when using keyboard navigation. Mixing pointer and keyboard navigation can result in the focus rings showing inconsistently, but that is expected. Are you expecting the focus ring to show in response to pointer clicks? I would keep in mind that |
|
@asyncliz I'm wondering if you know why when I'm trying to build a screenshot test and trying to access md-menu, it just hangs and throws If I then run it in the browser directly (it opens), I get: I tried element.dropdown and failed the same and which is why I tried querySelector but that also fails. The thing is when I use the debug logs, I see it outputs the md-menu element. The test is https://gerrit-review.googlesource.com/c/gerrit/+/483441/12/polygerrit-ui/app/elements/change/gr-copy-links/gr-copy-links_screenshot_test.ts. I had to create a button element to add to anchor element as we add the button in the parent element to that element. Seems anchor is required in order for the menu to show? |
|
Oh... seems md-menu doesn't like having |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi, I'm trying to migrate from iron-dropdown to md-menu. We do https://github.com/GerritCodeReview/gerrit/blob/master/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.ts#L187. I have a couple of issues.
Issue 1 is I can't access this.dropdown.open (always returns false) within that for enter, space, up or down.
Seems that the shortcut callback is triggered after md-menu has closed (if it was open) hence why .open was always false. Seems to work with iron-dropdown and I’m not sure how to fix it for md-menu. I found an workaround below, but would have preferred continuing using shortcut.
Issue 2 is I found a workaround to issue 1 with something like:
Which allows me to use this.dropdown.open and seems to generally work. So lets go to the issue, when I press enter or space it closes correctly and when I re-open it, it correctly shows the focus rings. Now when I go to a change, those focus rings don't show when I re-open the dropdown.
See https://imgur.com/a/T8ZDWTX
How do I fix? (Source code for the entire thing: https://gist.github.com/paladox/ccdc1971831ed31bf52fa8f96734fee9)
All reactions