Skip to content

ui: keep the docs version dropdown menu inside the viewport on narrow screens - #5349

Open
ngocanhnckh wants to merge 1 commit into
react:mainfrom
ngocanhnckh:fix/version-dropdown-overflow
Open

ngocanhnckh wants to merge 1 commit into
react:mainfrom
ngocanhnckh:fix/version-dropdown-overflow

Conversation

@ngocanhnckh

Copy link
Copy Markdown

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 as scrollWidth - clientWidth of 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__menu is positioned left: 0 relative 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-started and 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: passes
  • npx prettier --check src/css/docs-secondary-nav.scss (in website/): passes

Before/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.

Width Before After
320px, light Before, 320px light After, 320px light
320px, dark Before, 320px dark After, 320px dark
375px, light Before, 375px light After, 375px light
375px, dark Before, 375px dark After, 375px dark

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/flatlist and /docs/getting-started at 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.

… 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.
@meta-cla

meta-cla Bot commented Nov 24, 2026

Copy link
Copy Markdown

Hi @ngocanhnckh!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant