fix(widgets): keep the collapsed panel wide enough for its summary

The collapsed floating header reserves the widest rate, and a collapsed
panel is at least as wide as its header, so a panel resized to its
least width no longer cuts off the rates. The expanded width and the
resize limits are unchanged.
This commit is contained in:
Zakk committed 2026-10-04 20:43:39 +11:00
1 parent e881752c02
commit d514b4958a
5 files changed
+42 -5

No files matched your search

+1
View File
@@ -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.
+31
View File
@@ -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');
+1 -1
View File
@@ -195,7 +195,7 @@ export function PanelHeader({
</Button>
)
}
summary={collapsed ? <SpeedSummary /> : undefined}
summary={collapsed ? <SpeedSummary reserveWidth={!docked} /> : undefined}
actions={
<>
<MoreMenu
+3 -2
View File
@@ -308,8 +308,8 @@ function useEdgeHide(edge: EdgeHide | undefined, settled: boolean, laidOut: stri
// by arrow keys. The handles draw nothing but their cursor and, from the keyboard, a focus ring. A panel left in the
// frame's upper half keeps its top edge and one in the lower half its bottom edge, so expanding or resizing grows it
// towards the room; the frame keeps it inside the viewport. Dropping the header over `dockTarget` docks the panel
// instead of moving it. A collapsed panel is its header alone and keeps only its width; expanding restores the stored
// height. A `locked` panel keeps its place and size: it renders no move or resize handles, so neither pointer nor
// instead of moving it. A collapsed panel is its header alone and keeps only its width, or the header's whole content
// where that is wider; expanding restores the stored height. A `locked` panel keeps its place and size: it renders no move or resize handles, so neither pointer nor
// keyboard moves it, while the frame still keeps it inside the viewport. With `edge` the panel hides at the screen edge
// nearest to it behind a handle, as useEdgeHide describes.
export function FloatingPanel({
@@ -441,6 +441,7 @@ export function FloatingPanel({
ref={panel}
className="rp-floating-panel"
aria-label={label}
data-collapsed={collapsed || undefined}
{...hiding.panelProps}
style={
{
+6 -2
View File
@@ -42,6 +42,10 @@
flex-direction: column;
gap: var(--rp-space-3);
}
/* A collapsed panel is never narrower than its header, so the rates keep their reserved width beside the buttons. */
.rp-floating-panel[data-collapsed] {
min-inline-size: max-content;
}
/* The collapse chevron points the way the panel grows or shrinks: down from a panel kept by its top edge. */
.rp-floating-frame[data-anchor='top'] .rp-widget-collapse > 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));