-
Notifications
You must be signed in to change notification settings - Fork 896
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
md-menu/md-select overlay positions itself too far to the left side of the anchor element #5522
Comments
Further info: The problem may be with how There may be other limitations at play here, but I am not aware of them. |
Does this happen outside the catalog as well? If so, can you post a reproduction and the browsers it occurs on? I wasn't able to reproduce in Chrome or Firefox on macOS at https://material-web.dev/components/select/stories/, so it may be an issue just with the inline demos. |
Yes, I randomly encountered the issue while working on an unrelated project.
I can also confirm that the storyboard works properly. In regards to the initial issues in Chrome 122.0.6261.112 (Official Build) (64-bit), here's is a repro . Same repro seems to work fine in Firefox 123.0.1 (64bit), so maybe there are 2 unrelated issues. Both tests have been done in Windows 11. Trying to pinpoint the problem was a pain, however from what I've seen so far it happens only under certain conditions. Perhaps something to do with overflows and scrollbars during position calculations? Setting Changing the On my screen (Chrome 122.0.6261.112) it looks like this: |
After further investigation I found the culprit but wouldn't know if the fix I have in mind would impact something else. Could you take a look please? @asyncLiz The problem seems to be that
getBoundingClientRect() a few lines below. Calling either anchorEl.getSurfacePositionClientRect() or anchorEl.getBoundingClientRect() before and after the showPopover() call will result in two different x values.
I have no idea why it does what it does. Again, it's in Chromium based browsers (tested Chrome and Edge, Firefox is fine) on Windows. The fix would be to move the following lines above the material-web/menu/internal/controllers/surfacePositionController.ts Lines 228 to 230 in 713f0a8
|
@e111077 at a glance do you see any problems with doing the anchor rect calculations before calling |
I vaguely remember a bug where an absolute (non native popover) surface may resize the document (e.g. introduce scrollbars) and not match the final location of the anchor in the case where the |
As far as I understand, that material-web/menu/internal/menu.ts Lines 485 to 497 in 713f0a8
So changing the order of those 2 calls should be insignificant unless, |
What is affected?
Component
Description
When using md-menu with positioning
popover
ordocument
the overlay goes 10ish? pixels too far to the left side of the anchor.The expected behavior would be for the overlay to be left? aligned with the anchor button.
This is also a problem in md-select, which is where I initially noticed the problem.
Reproduction
The problems are visible on the material-web.dev website already
https://material-web.dev/components/menu/#popover-positioned-menus
https://material-web.dev/components/menu/#document-positioned-menus
And the select:
https://material-web.dev/components/select/#usage
Workaround
I have not found a workaround.
Is this a regression?
No or unsure. This never worked, or I haven't tried before.
Affected versions
1.3.0
Browser/OS/Node environment
Browser: Version 122.0.6261.112 (Official Build) (64-bit)
OS: Windows 11 Pro, version 23H2, build 22631.3155
Node version: v20.11.0
npm version: 9.6.7
The text was updated successfully, but these errors were encountered: