Skip to content

fix: resolve floating MUI dropdown on scroll by correcting html overflow property#7478

Open
YASHMAHAKAL wants to merge 1 commit intolayer5io:masterfrom
YASHMAHAKAL:fix-floating-dropdown
Open

fix: resolve floating MUI dropdown on scroll by correcting html overflow property#7478
YASHMAHAKAL wants to merge 1 commit intolayer5io:masterfrom
YASHMAHAKAL:fix-floating-dropdown

Conversation

@YASHMAHAKAL
Copy link
Contributor

@YASHMAHAKAL YASHMAHAKAL commented Mar 10, 2026

Description

This PR fixes an issue where Material UI (MUI) Select dropdowns "float" and detach from their anchor element when the page is scrolled.

Signed commits

  • Yes, I signed my commits.

@l5io
Copy link
Member

l5io commented Mar 10, 2026

🚀 Preview for commit 403d744 at: https://69b051260346db73e024c9b7--layer5.netlify.app

@YASHMAHAKAL YASHMAHAKAL marked this pull request as draft March 10, 2026 17:17
@YASHMAHAKAL YASHMAHAKAL force-pushed the fix-floating-dropdown branch 2 times, most recently from fc25462 to 7c348a1 Compare March 10, 2026 17:43
@l5io
Copy link
Member

l5io commented Mar 10, 2026

🚀 Preview for commit 7c348a1 at: https://69b05bd833b7968e41f17338--layer5.netlify.app

@l5io
Copy link
Member

l5io commented Mar 10, 2026

🚀 Preview for commit b8b17f2 at: https://69b0754194a91706bdcef16b--layer5.netlify.app

@leecalcote
Copy link
Member

We have floating dropdowns on the homepage?

@leecalcote
Copy link
Member

With this change how are mobile views supposed to handle overflowing content?

@leecalcote
Copy link
Member

We have floating dropdowns on the homepage?

I see now that we don't; that the PR description is inaccurate.

@YASHMAHAKAL
Copy link
Contributor Author

@leecalcote mine previous changes were incorrect, i haven't updated pr description, i will update it once i'm done. apologies for confusion : ) the problem is when we open any dropdown and scroll page the dropdown persists on whole page.

@l5io
Copy link
Member

l5io commented Mar 11, 2026

🚀 Preview for commit 92494ab at: https://69b16b09d79dc320caa9df7b--layer5.netlify.app

@l5io
Copy link
Member

l5io commented Mar 11, 2026

🚀 Preview for commit 39c6bdf at: https://69b174bdd79dc34fa5a9ddea--layer5.netlify.app

@YASHMAHAKAL
Copy link
Contributor Author

@saurabhraghuvanshii i have enforced scroll-lock when dropdown is opened, lock is disabled when we close dropdown. is this expected behaviour or do we need scroll even when dropdown is open ?

@YASHMAHAKAL YASHMAHAKAL marked this pull request as ready for review March 11, 2026 14:14
@YASHMAHAKAL YASHMAHAKAL force-pushed the fix-floating-dropdown branch from 39c6bdf to 073fd93 Compare March 11, 2026 14:31
Because body has overflow:clip, <html> is the actual scroll container. This rule
synchronizes the lock — when MUI locks body, we also lock html to prevent scrolling. */
html:has(body[style*="overflow: hidden"]) {
overflow: hidden !important;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YASHMAHAKAL we don't prefer !important usually. try diff method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay : )

@l5io
Copy link
Member

l5io commented Mar 11, 2026

🚀 Preview for commit 073fd93 at: https://69b180241d9a1c18c4f6c92b--layer5.netlify.app

Signed-off-by: YASHMAHAKAL <yvsst01@gmail.com>
@YASHMAHAKAL YASHMAHAKAL force-pushed the fix-floating-dropdown branch from 073fd93 to 4ad58fc Compare March 11, 2026 16:39
Comment on lines +63 to +64
html:has(body[style*="overflow: hidden"]) {
overflow: hidden;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 185 to 193
background-color: ${(props) => props.theme.shadowDarkColor}!important;
color: ${(props) => props.theme.text};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

however search box is also having !important, i have confirmed it's in master also

@l5io
Copy link
Member

l5io commented Mar 11, 2026

🚀 Preview for commit 4ad58fc at: https://69b19e4d8d3435403fdd6477--layer5.netlify.app

@saurabhraghuvanshii
Copy link
Member

YASHMAHAKAL, when I open the dropdown, I’m unable to scroll the page down.

@YASHMAHAKAL
Copy link
Contributor Author

@saurabhraghuvanshii i have enforced scroll-lock when dropdown is opened, lock is disabled when we close dropdown. is this expected behaviour or do we need scroll even when dropdown is open ?

@saurabhraghuvanshii yes, it wont as i said earlier, you need to either select or close the dropdown to scroll.. should i configure it otherwise ?

@saurabhraghuvanshii
Copy link
Member

My bad, I missed that comment. Sorry. Yes, we need the user to be able to scroll the page; only the dropdown should stay fixed.

@YASHMAHAKAL
Copy link
Contributor Author

@saurabhraghuvanshii alright

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants