Skip to content

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

Merged
saurabhraghuvanshii merged 3 commits intolayer5io:masterfrom
YASHMAHAKAL:fix-floating-dropdown
Mar 14, 2026
Merged

fix: resolve floating MUI dropdown on scroll by correcting html overflow property#7478
saurabhraghuvanshii merged 3 commits intolayer5io:masterfrom
YASHMAHAKAL:fix-floating-dropdown

Conversation

@YASHMAHAKAL
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

l5io commented Mar 10, 2026

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

@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 10, 2026

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

@leecalcote
Copy link
Copy Markdown
Member

We have floating dropdowns on the homepage?

@leecalcote
Copy link
Copy Markdown
Member

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

@leecalcote
Copy link
Copy Markdown
Member

We have floating dropdowns on the homepage?

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

@YASHMAHAKAL
Copy link
Copy Markdown
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
Copy Markdown
Member

l5io commented Mar 11, 2026

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

@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 11, 2026

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

@YASHMAHAKAL
Copy link
Copy Markdown
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;
Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member

l5io commented Mar 11, 2026

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

@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
Copy Markdown
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
Copy link
Copy Markdown
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
Copy Markdown
Member

l5io commented Mar 11, 2026

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

@saurabhraghuvanshii
Copy link
Copy Markdown
Member

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

@YASHMAHAKAL
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

@saurabhraghuvanshii alright

Signed-off-by: YASHMAHAKAL <yvsst01@gmail.com>
Signed-off-by: YASHMAHAKAL <yvsst01@gmail.com>
@YASHMAHAKAL YASHMAHAKAL force-pushed the fix-floating-dropdown branch from 4ad58fc to be08147 Compare March 14, 2026 16:54
@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 14, 2026

🚀 Preview for commit be08147 at: https://69b5962a7678236bcef42ac0--layer5.netlify.app

@YASHMAHAKAL
Copy link
Copy Markdown
Contributor Author

@saurabhraghuvanshii now dropdowns are attached to the anchor and doesn't floats all over the page when scrolling and also scroll lock is disabled while dropdown is opened, let me know if further iterations required : )

Signed-off-by: YASHMAHAKAL <yvsst01@gmail.com>
@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 14, 2026

🚀 Preview for commit e8d428c at: https://69b5ac5b55d43c699769b06d--layer5.netlify.app

@saurabhraghuvanshii saurabhraghuvanshii merged commit b8248ed into layer5io:master Mar 14, 2026
4 checks passed
@saurabhraghuvanshii
Copy link
Copy Markdown
Member

THanks @YASHMAHAKAL

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