diff --git a/changes/fix-pinned-panel-locked.md b/changes/fix-pinned-panel-locked.md index 07f371d1..3c5daed8 100644 --- a/changes/fix-pinned-panel-locked.md +++ b/changes/fix-pinned-panel-locked.md @@ -4,3 +4,4 @@ Fixed - The widgets panel now starts unpinned. - The docked panel drops its title and has an Undock button where the floating panel has its pin; the menu no longer offers Undock. - A byte fraction writes a unit both sides share once, as in 70/268 MB, so the docked memory meter, now labelled cgroup used, fits on one row. +- A narrow collapsed panel shows both rates whole beside its buttons. diff --git a/e2e/widgets.spec.ts b/e2e/widgets.spec.ts index 68cc04aa..7b0389f0 100644 --- a/e2e/widgets.spec.ts +++ b/e2e/widgets.spec.ts @@ -795,6 +795,37 @@ test('a pinned panel keeps its place and size; unpinned, it moves and resizes ag await expect.poll(async () => (await box(panel)).width).toBe(moved.width + 40); }); +test('a panel resized to its least width and collapsed shows both rates whole beside its buttons', async ({page}) => { + const backend = await mockBackend(page); + backend.handlers['GET runtime'] = async () => { + const runtime = await backend.api.runtime(); + return {...runtime, traffic: {...runtime.traffic, rates: {upload_bytes_per_second: '999000000', download_bytes_per_second: '999000000'}}}; + }; + await page.goto('/#/settings'); + const panel = floating(page); + await panel.getByRole('button', {name: 'Resize widgets panel', exact: true}).focus(); + for (let i = 0; i < 6; i++) await page.keyboard.press('ArrowRight'); + await expect.poll(async () => (await box(panel)).width).toBe(200); + await panel.getByRole('button', {name: 'Collapse widgets', exact: true}).click(); + const values = panel.locator('.rp-widget-speed-value'); + await expect(values).toHaveText(['999 MB/s', '999 MB/s']); + const fit = await panel.evaluate(el => { + const actions = el.querySelector('.rp-widget-actions')!.getBoundingClientRect(); + const frame = el.getBoundingClientRect(); + return [...el.querySelectorAll('.rp-widget-speed-value')].map(value => { + const rect = value.getBoundingClientRect(); + return {whole: value.scrollWidth <= value.clientWidth, clear: rect.right <= actions.left, inside: actions.right <= frame.right}; + }); + }); + expect(fit).toEqual([ + {whole: true, clear: true, inside: true}, + {whole: true, clear: true, inside: true} + ]); + // Expanded again, the panel keeps the width the reader set. + await panel.getByRole('button', {name: 'Expand widgets', exact: true}).click(); + await expect.poll(async () => (await box(panel)).width).toBe(200); +}); + test('the default panel draws both rates in one chart without scrolling', async ({page}) => { await page.goto('/#/settings'); const chart = floating(page).locator('.rp-compact-chart'); diff --git a/src/shell/widgets/Widgets.tsx b/src/shell/widgets/Widgets.tsx index 05b274ec..2dee7ed6 100644 --- a/src/shell/widgets/Widgets.tsx +++ b/src/shell/widgets/Widgets.tsx @@ -195,7 +195,7 @@ export function PanelHeader({ ) } - summary={collapsed ? : undefined} + summary={collapsed ? : undefined} actions={ <> svg { rotate: 180deg; @@ -193,8 +197,8 @@ box-shadow: var(--rp-elevated); pointer-events: auto; } -/* The widest rate after its icon, so the handle keeps one width as the rates change. */ -.rp-edge-handle .rp-widget-speed::before { +/* The widest rate after its icon, so a summary with a reserved width keeps it as the rates change. */ +.rp-widget-speed[data-reserve]::before { content: attr(data-reserve); block-size: 0; padding-inline-start: calc(var(--rp-line-caption) + var(--rp-space-1));