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

BUG: The dropdown doesn't take into account the scrollbar. #6657

Open
AnupamKhosla opened this issue Sep 15, 2021 · 5 comments
Open

BUG: The dropdown doesn't take into account the scrollbar. #6657

AnupamKhosla opened this issue Sep 15, 2021 · 5 comments

Comments

@AnupamKhosla
Copy link

AnupamKhosla commented Sep 15, 2021

Have a look at the following demo: https://jsfiddle.net/qejvb51s/ Make the screen less than 485px so that the dropdown has to be pushed to the right.

As you can see the dropdown width should have removed scrollbar width from its calculations. At the moment when a webpage has a scrollbar(which is 99% of the websites) the dropdown with dynamic content/width causes horizontal scrolling.

I assume this is an important bug. Do you guys know of a workaround?

@JordanHillDev
Copy link

Can you assign me? I was able to fix the issue in the demo. Changing the .right class position to relative worked for me, but I'd like to try it for real.

@AnupamKhosla
Copy link
Author

Can you assign me? I was able to fix the issue in the demo. Changing the .right class position to relative worked for me, but I'd like to try it for real.

Really interesting!, how would you guess that? Do you know why does that fix the issue? It wouldn't always be possible to have a relatively positioned parent for the dropdown content; it might break other things in the website.

Secondly consider this demo https://jsfiddle.net/8xtpw23v/1/ I have assigned container: "body" in the initialization. The bug would persist in this scenario.

Thirdly I don't know what you mean by "Can you assign me".

@JordanHillDev
Copy link

Whatever the container is assigned to determines the size of the dropdown. It seems like an easy fix is to assign the container to the list item that triggers the dropdown. No relative positioning necessary. https://jsfiddle.net/y76vzpba/3/

I'm pretty new to open source so I thought I needed assigned to work on a project. My bad.

@AnupamKhosla
Copy link
Author

It seems like we have a slight communication barrier. Your demo https://jsfiddle.net/y76vzpba/3/ does not work properly for screen size less than 475px. You need to have a relatively positioned parent(li in your case which you have commented styles given).

I found another workaround, which is to give width: 100% to the containing parent of the dropdown: https://jsfiddle.net/gvwsmb6p/

I guess the dropdown plugin uses window.innerWidth instead of document.body.clientWidth. It might be taking into account the width of nearest relatively positioned parent, as the .dropdown-content itself is absolutely positioned. I'm gonna have to dig into the source code to see why these workarounds are working.

@DanielRuf
Copy link
Contributor

You might want to report these issues at https://github.com/materializecss/materialize which is an actively maintained fork.

PRs are very welcome there and will be reviewed, merged and new contributors will become members of the org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants