material-components-web icon indicating copy to clipboard operation
material-components-web copied to clipboard

[MDCMenu] Menu prioritizes anchor position over visibility

Open manuela-beckert opened this issue 3 years ago • 3 comments

Bug report

We use menus with icon buttons as anchor in our project for e.g. managing time. The menu contains a small UI that takes up some horizontal space.

We noticed that on lower screen width, if the menu anchor is near the center of the screen, the menu will be cut off, even though there is in theory enough space. But the menu seems to prioritize touching the anchor with one corner over being visible.

We feel like it should be the other way around.

Steps to reproduce

  1. Create a menu with small anchor and high surface width (at least half the screen size)
  2. Position the menu anchor horizontally centered
  3. Open the menu

Actual behavior

The menu is cut off.

Expected behavior

The menu is moved into the viewport.

Screenshots

image

Your Environment:

Software Version(s)
MDC Web 13.0.0
Browser Google Chrome 96.0.4664.93
Operating System Ubuntu 18.04.6 LTS

manuela-beckert avatar Dec 08 '21 13:12 manuela-beckert

Hey Manuela, thank you for the issue.

To clarify, is the anchor in the above screenshot the container of the whole group of icon buttons, or just one icon button? It appears that the top left corner of the menu is lined up with the left bottom corner of the icon button group (not the "timer" button).

One strategy that has worked well in other similar cases is to use the right anchor corner for positioning (so that menu grows to the left), given the general positioning of the icon buttons in your layout towards the right side of the page.

allan-chen avatar Dec 09 '21 19:12 allan-chen

It's anchored on this icon: image

Right, we actually do use the right corner in our system. This screenshot was just to highlight the issue.

On bigger screen width, there is enough space for it to expand on the left. This is really about lower screen width only. And on lower screen width it would just lead to the menu being cut off on the left.

manuela-beckert avatar Dec 10 '21 09:12 manuela-beckert

I'm having the same issue. It seems to flip the horizontal direction when there is enough space on the left. But on smaller screens there might not be enough space on the left to flip the whole menu. It seems to me that in such a case the menu should not flip but shift enough that it doesn't overflow viewport.

HarlesPilter avatar Feb 17 '22 22:02 HarlesPilter