Repository navigation
ui: keep the docs version dropdown menu inside the viewport on narrow screens - #5349
ngocanhnckh wants to merge 1 commit into
Conversation
… screens The menu is left-aligned with its toggle, so below ~410px wide it extended past the right edge of the viewport and made every docs page scroll sideways, even while hidden. Right-align it to the toggle at 480px and below.
|
Hi @ngocanhnckh! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
What is broken
On every docs page (
/docs/...), the version dropdown in the secondary nav ("0.88" pill) makes the page scroll sideways on phones. Measured asscrollWidth - clientWidthof the document: 320px = +86px, 360px = +46px, 375px = +31px, 390px = +16px, 400px = +6px. 414px and wider are fine. When the menu is opened it also hangs off the right edge of the screen (the "Next" / version list is cut off).Root cause
.dropdown__menuis positionedleft: 0relative to its toggle. The toggle sits about 236px from the left edge (after the "Docs" title and the section dropdown) and the menu is 170px wide, so it ends at about x=406. Even while hidden (visibility: hidden) the absolutely positioned menu extends the scrollable area of the page.Fix
In
website/src/css/docs-secondary-nav.scss, right-align the version dropdown menu to its toggle at 480px and below (left: auto; right: 0). At 320px the menu then spans x=138 to 308 and is fully visible. Wider screens are unchanged.Testing
Local
yarn start(Node 22), measured with Playwright on/docs/flatlist,/docs/view,/docs/getting-startedand a versioned page (/docs/0.80/flatlist) at 320, 360, 375, 390, 414, 480, 600, 768, 820, 996, 1024 and 1440px: horizontal overflow is 0 everywhere after the change (before: 86/46/31/16 at 320/360/375/390 on flatlist and view; 44 and 4 at 320 and 360 on getting-started). The menu was opened by hover at 320px and 375px in light and dark themes and fits on screen.yarn --cwd website lint:styles: passesnpx prettier --check src/css/docs-secondary-nav.scss(inwebsite/): passesBefore/after (menu open, cropped to the top of the page; the red box on the "before" images marks the menu that overflows):
The red boxes in the before shots mark the broken part.
I maintain renderlint, an open-source CLI that renders pages in a headless browser and reports layout defects. I found this with a width sweep rather than with renderlint (it does not report this page-level overflow), but I ran it on
/docs/flatlistand/docs/getting-startedat 375, 768 and 1280px before and after the change and it reports no new findings. If it would be useful, I'm happy to open a follow-up PR that runs it on the docs in CI; no pressure either way.