Skip to content
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

Menu dropdown panel renders incorrectly with filter on Chrome #265

Closed
threeseed opened this issue Nov 5, 2020 · 2 comments
Closed

Menu dropdown panel renders incorrectly with filter on Chrome #265

threeseed opened this issue Nov 5, 2020 · 2 comments
Assignees
Labels
bug Things that aren't working right in the library.

Comments

@threeseed
Copy link

threeseed commented Nov 5, 2020

When you use a menu within a div that is applying a filter on hover it renders incorrectly.
It is only an issue with Chrome and only an issue when using a filter.

To Reproduce
Steps to reproduce the behavior:

  1. Visit https://jsfiddle.net/18b6Lvfx/1/
  2. Click on the button to open the menu panel.
  3. Hover your mouse over the background-image and notice how the menu panel also moves.

Expected behavior
If you try with Safari you see the expected behaviour i.e. menu panel doesn't move.

Desktop (please complete the following information):

  • OSX: 10.15.7 (19H2)
  • Browser: Chrome
  • Version: 78.0.3904.87 (Official Build) (64-bit)
@threeseed threeseed added the bug Things that aren't working right in the library. label Nov 5, 2020
@claviska
Copy link
Member

claviska commented Nov 5, 2020

While this behavior isn't straight-forward, it's not a bug. It's a side effect of using a fixed positioning strategy via hoist and how fixed positioning works in HTML/CSS. From the docs:

Dropdown panels will be clipped if they're inside a container that has overflow: auto|hidden. The hoist attribute forces the panel to use a fixed positioning strategy, allowing it to break out of the container. In this case, the panel will be positioned relative to its containing block, which is usually the viewport unless an ancestor uses a transform, perspective, or filter. Refer to this page for more details.

In your case, removing the hoist prop will resolve it (unless your use case requires overflow: hidden).

The reason two positioning strategies are offered is because everything is contained in the <sl-dropdown> component and, depending on how it's used, you may need to break a dropdown panel out of an overflow: hidden container from time to time.

Because dropdowns use a shadow root and everything is contained in it, traditional hoisting can't be done (e.g. moving the panel to just before </body> when it's activated). This is because styles are encapsulated so those plus slots stop working when you move things outside of the shadow root.

What we really need is something like position: popover:

image

Before landing on the current API, I experimented heavily with different hoisting options, including moving things around in the DOM, cloning the panel, creating a separate component for the panel — none of them were clean solutions, nor did they provide an intuitive API for users.

That said, I'm closing this since the behavior is documented and expected. The only way I can think to address this sanely in the future will be with a new CSS property.

@claviska claviska closed this as completed Nov 5, 2020
@claviska
Copy link
Member

claviska commented Nov 5, 2020

I finally took the time to start this discussion with the CSS WG. If you're interested, you can follow along here: w3c/csswg-drafts#5699

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that aren't working right in the library.
Projects
None yet
Development

No branches or pull requests

2 participants