material-components / material-components/material-web

md-menu/md-select overlay positions itself too far to the left side of the anchor element

Open
#5,522 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
SCSS
Stars
11.3k
Forks
1.1k
Avg merge
20h 28m
Merged PRs (30d)
13

Description

### What is affected?

Component

### Description

When using **md-menu** with _positioning_ `popover` or `document` 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.

![image](https://github.com/material-components/material-web/assets/4929965/d041dc32-e864-44ff-b7a9-d2da44d21414)

### Reproduction

The problems are visible on the material-web.dev website already
https://material-web.dev/components/menu/#popover-positioned-menus

![image](https://github.com/material-components/material-web/assets/4929965/5efd9380-ecda-464b-b5fa-240c4144ebe5)

https://material-web.dev/components/menu/#document-positioned-menus

![image](https://github.com/material-components/material-web/assets/4929965/d0c518b6-d885-4e48-ab8d-4aea0a74e518)

And the select:
https://material-web.dev/components/select/#usage
![image](https://github.com/material-components/material-web/assets/4929965/e2098d91-0af8-4d3f-9284-533468bb5e30)

### 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the offset in the linked md-menu popover-positioned and document-positioned demos, then compare the md-select usage demo. Trace the positioning entry points for the popover and document modes; done means both overlays are left-aligned with their anchor elements without breaking either component.

Written by the indexing model from the issue text.

Assessment

Tech stack
scss
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.