Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions TESTING_COVERAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 32 additions & 9 deletions browser/data-browser/src/components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function TagSelectPopoverWrapper({ resource }: { resource: Resource }) {

if (driveSubject === undefined || resource.loading) {
return (
<LabelButton disabled>
<LabelButton disabled title='Tags'>
<FaTags />
<span>Tags</span>
</LabelButton>
Expand All @@ -113,6 +113,7 @@ function TagSelectPopoverWrapper({ resource }: { resource: Resource }) {
<LabelButton
as={RadixPopover.Trigger}
data-testid='navbar-tags-button'
title='Tags'
>
<FaTags />
<span>Tags</span>
Expand Down Expand Up @@ -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<HTMLElement>(null);
const actionAreaRef = useRef<HTMLDivElement>(null);
const collapseWidthRef = useRef(0);
const [iconOnly, setIconOnly] = useState(false);

Expand All @@ -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) {
Expand Down Expand Up @@ -349,7 +354,7 @@ export function NavBar({ resource: resourceProp }: NavBarProps): JSX.Element {
<EditableBreadcrumb resource={resource} fallback={title} />
</CrumbGroup>
<Spacer />
<ButtonArea $iconOnly={iconOnly}>
<ButtonArea ref={actionAreaRef} $iconOnly={iconOnly}>
<FollowStatus />
<MeetingBanner />
<ContentLanguageSelect />
Expand Down Expand Up @@ -387,20 +392,24 @@ export function NavBar({ resource: resourceProp }: NavBarProps): JSX.Element {
<ShareDialog
subject={contextResource.subject}
trigger={
<LabelButton as='button'>
<LabelButton as='button' title='Share'>
<FaShare />
<span>Share</span>
</LabelButton>
}
/>
<ResourceContextMenu
isMainMenu
subject={contextResource.subject}
trigger={ParentContextMenuTrigger}
/>
</>
)}
</ButtonArea>
{contextResource && (
<MenuSlot $iconOnly={iconOnly}>
<ResourceContextMenu
isMainMenu
subject={contextResource.subject}
trigger={ParentContextMenuTrigger}
/>
</MenuSlot>
)}
</NavBarWrapper>
);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 <b>: ButtonArea's icon-only rule hides <span>s
Expand Down
9 changes: 8 additions & 1 deletion browser/data-browser/src/components/NavBarButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions browser/data-browser/src/locales/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions browser/data-browser/src/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions browser/data-browser/src/locales/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions browser/data-browser/src/locales/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions browser/e2e/tests/sidebar-layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
});
Loading