From ede8ad0cd5cd0debf4ad11c27c8d91373695bdc1 Mon Sep 17 00:00:00 2001 From: Joep Meindertsma Date: Wed, 23 Sep 2026 09:38:49 +0200 Subject: [PATCH] Fix mobile resource menu visibility --- TESTING_COVERAGE.md | 2 + .../data-browser/src/components/NavBar.tsx | 41 +++++++++++++++---- .../src/components/NavBarButton.tsx | 9 +++- browser/data-browser/src/locales/de.po | 3 ++ browser/data-browser/src/locales/en.po | 3 ++ browser/data-browser/src/locales/es.po | 3 ++ browser/data-browser/src/locales/fr.po | 3 ++ browser/e2e/tests/sidebar-layout.spec.ts | 21 ++++++++++ 8 files changed, 75 insertions(+), 10 deletions(-) diff --git a/TESTING_COVERAGE.md b/TESTING_COVERAGE.md index d46d377aaf..dbfd89c809 100644 --- a/TESTING_COVERAGE.md +++ b/TESTING_COVERAGE.md @@ -2473,6 +2473,8 @@ triggers and verifies only action labels disappear. `presence-follow.spec.ts` uses two tabs sharing one stored test identity, checks the avatar at 320px, opens Follow and verifies subsequent navigation. The updated Chromium test passed against the local app; cross-network staging presence was not certified. +`sidebar-layout.spec.ts` checks the resource menu stays inside 390px and 320px +viewports, action labels collapse, and the menu opens on tap. `recovery-fetch.test.ts` verifies 429 cooldowns (Retry-After seconds and a 60-second fallback), retry after expiry, in-flight sharing and fresh successful diff --git a/browser/data-browser/src/components/NavBar.tsx b/browser/data-browser/src/components/NavBar.tsx index db81ed3a6a..daa32e7cef 100644 --- a/browser/data-browser/src/components/NavBar.tsx +++ b/browser/data-browser/src/components/NavBar.tsx @@ -94,7 +94,7 @@ function TagSelectPopoverWrapper({ resource }: { resource: Resource }) { if (driveSubject === undefined || resource.loading) { return ( - + Tags @@ -113,6 +113,7 @@ function TagSelectPopoverWrapper({ resource }: { resource: Resource }) { Tags @@ -253,6 +254,7 @@ export function NavBar({ resource: resourceProp }: NavBarProps): JSX.Element { // remembers the width at which labels last overflowed and only re-expands // clearly above it, so it settles instead of flip-flopping at the boundary. const navRef = useRef(null); + const actionAreaRef = useRef(null); const collapseWidthRef = useRef(0); const [iconOnly, setIconOnly] = useState(false); @@ -262,7 +264,10 @@ export function NavBar({ resource: resourceProp }: NavBarProps): JSX.Element { if (!nav) return; const width = nav.clientWidth; - const overflowing = nav.scrollWidth > width + 1; + const actions = actionAreaRef.current; + const overflowing = + nav.scrollWidth > width + 1 || + (actions !== null && actions.scrollWidth > actions.clientWidth + 1); setIconOnly(prev => { if (overflowing) { @@ -349,7 +354,7 @@ export function NavBar({ resource: resourceProp }: NavBarProps): JSX.Element { - + @@ -387,20 +392,24 @@ export function NavBar({ resource: resourceProp }: NavBarProps): JSX.Element { + Share } /> - )} + {contextResource && ( + + + + )} ); } @@ -431,6 +440,7 @@ function CommentsButton({ subject }: { subject: string }): JSX.Element { const NavBarWrapper = styled.nav` height: 100%; width: 100%; + box-sizing: border-box; padding-inline: ${p => p.theme.size(1)}; display: flex; flex-direction: row; @@ -510,6 +520,19 @@ const CommentsLabelButton = styled(LabelButton)` } `; +/** Reserve the trailing edge for the resource menu even when other actions grow. */ +const MenuSlot = styled.div<{ $iconOnly: boolean }>` + flex-shrink: 0; + + ${p => + p.$iconOnly && + css` + ${LabelButton} > span { + display: none; + } + `} +`; + /** * Rendered in place of the comment icon, matching its 1em footprint so the * navbar doesn't shift. Uses : ButtonArea's icon-only rule hides s diff --git a/browser/data-browser/src/components/NavBarButton.tsx b/browser/data-browser/src/components/NavBarButton.tsx index 03a221e3d7..00a569b3a8 100644 --- a/browser/data-browser/src/components/NavBarButton.tsx +++ b/browser/data-browser/src/components/NavBarButton.tsx @@ -31,6 +31,12 @@ export const LabelButton = styled.button<{ $active?: boolean }>` font-size: 1rem; } + @container breadcrumb-bar (max-width: 600px) { + > span { + display: none; + } + } + &[disabled] { opacity: 0.5; cursor: not-allowed; @@ -55,7 +61,8 @@ export const ButtonArea = styled.div<{ $iconOnly: boolean }>` color: ${p => p.theme.colors.textLight}; gap: ${p => p.theme.size(1)}; align-items: center; - flex-shrink: 0; + min-width: 0; + overflow: hidden; @container breadcrumb-bar (max-width: 600px) { gap: 0; diff --git a/browser/data-browser/src/locales/de.po b/browser/data-browser/src/locales/de.po index 06e308a46f..bab3342515 100644 --- a/browser/data-browser/src/locales/de.po +++ b/browser/data-browser/src/locales/de.po @@ -1083,6 +1083,8 @@ msgstr "" msgid "Resources" msgstr "" +#: src/components/NavBar.tsx +#: src/components/NavBar.tsx #: src/components/NavBar.tsx #: src/components/NavBar.tsx #: src/components/NavBar.tsx src/views/Drive/DrivePage.tsx @@ -2446,6 +2448,7 @@ msgstr "" msgid "Accept Changes" msgstr "" +#: src/components/NavBar.tsx #: src/components/NavBar.tsx #: src/components/NavBar.tsx src/components/Share/ShareDialog.tsx #: src/components/Share/ShareDialog.tsx diff --git a/browser/data-browser/src/locales/en.po b/browser/data-browser/src/locales/en.po index b45cb20975..dc779450ea 100644 --- a/browser/data-browser/src/locales/en.po +++ b/browser/data-browser/src/locales/en.po @@ -1083,6 +1083,8 @@ msgstr "Add description" msgid "Resources" msgstr "Resources" +#: src/components/NavBar.tsx +#: src/components/NavBar.tsx #: src/components/NavBar.tsx #: src/components/NavBar.tsx #: src/components/NavBar.tsx src/views/Drive/DrivePage.tsx @@ -2446,6 +2448,7 @@ msgstr "Revert" msgid "Accept Changes" msgstr "Accept Changes" +#: src/components/NavBar.tsx #: src/components/NavBar.tsx #: src/components/NavBar.tsx src/components/Share/ShareDialog.tsx #: src/components/Share/ShareDialog.tsx diff --git a/browser/data-browser/src/locales/es.po b/browser/data-browser/src/locales/es.po index 160e9b6387..04e6fe0610 100644 --- a/browser/data-browser/src/locales/es.po +++ b/browser/data-browser/src/locales/es.po @@ -1083,6 +1083,8 @@ msgstr "Añadir descripción" msgid "Resources" msgstr "Recursos" +#: src/components/NavBar.tsx +#: src/components/NavBar.tsx #: src/components/NavBar.tsx #: src/components/NavBar.tsx #: src/components/NavBar.tsx src/views/Drive/DrivePage.tsx @@ -2446,6 +2448,7 @@ msgstr "Deshacer cambios" msgid "Accept Changes" msgstr "Aceptar cambios" +#: src/components/NavBar.tsx #: src/components/NavBar.tsx #: src/components/NavBar.tsx src/components/Share/ShareDialog.tsx #: src/components/Share/ShareDialog.tsx diff --git a/browser/data-browser/src/locales/fr.po b/browser/data-browser/src/locales/fr.po index 39105a7eac..bb1a0fde79 100644 --- a/browser/data-browser/src/locales/fr.po +++ b/browser/data-browser/src/locales/fr.po @@ -1083,6 +1083,8 @@ msgstr "Ajouter une description" msgid "Resources" msgstr "Ressources" +#: src/components/NavBar.tsx +#: src/components/NavBar.tsx #: src/components/NavBar.tsx #: src/components/NavBar.tsx #: src/components/NavBar.tsx src/views/Drive/DrivePage.tsx @@ -2446,6 +2448,7 @@ msgstr "Annuler" msgid "Accept Changes" msgstr "Accepter les modifications" +#: src/components/NavBar.tsx #: src/components/NavBar.tsx #: src/components/NavBar.tsx src/components/Share/ShareDialog.tsx #: src/components/Share/ShareDialog.tsx diff --git a/browser/e2e/tests/sidebar-layout.spec.ts b/browser/e2e/tests/sidebar-layout.spec.ts index 1e29f99305..6f5f97d4b0 100644 --- a/browser/e2e/tests/sidebar-layout.spec.ts +++ b/browser/e2e/tests/sidebar-layout.spec.ts @@ -147,3 +147,24 @@ test('mobile sidebar stays an overlay and closes from its backdrop', async ({ await expect(sidebar).toHaveCSS('opacity', '0'); expect(await main.boundingBox()).toEqual(initial); }); + +test('mobile resource actions keep the menu on screen', async ({ page }) => { + for (const width of [390, 320]) { + await page.setViewportSize({ width, height: 844 }); + + const menuTrigger = page.locator('[data-test="context-menu"]'); + await expect(menuTrigger).toBeVisible(); + await expect( + page.getByTestId('navbar-tags-button').locator('span'), + ).toHaveCSS('display', 'none'); + + const bounds = await menuTrigger.boundingBox(); + expect(bounds).not.toBeNull(); + expect(bounds!.x + bounds!.width).toBeLessThanOrEqual(width); + expect(bounds!.x).toBeGreaterThanOrEqual(0); + + await menuTrigger.click(); + await expect(page.getByRole('menu')).toBeVisible(); + await page.keyboard.press('Escape'); + } +});