fix(lite): keep group names and the sidebar inset at mid widths

The group inspector kept its 640 px width (480 px minimum) at every
width, so between the phone breakpoint and about 1280 px the group list
shrank until the label column, which is the only part of a row that
yields, reached zero: names vanished and the latency overflowed the
row. Below about 1000 px the panel also covered the list.

The panel now leaves 22rem to the list and never takes less than 45% of
the row, so names keep room and ellipsize, and the latency stays whole.
From 1280 px the chosen width is unchanged.

The layout-rhythm check covers 1180 and 1470 px in en and zh-TW: every
group name keeps at least 64 px inside its row, the latency is not cut,
and the sidebar items have equal start and end insets.
This commit is contained in:
Zakk committed 2026-10-27 22:26:12 +00:00
1 parent c877c33b7b
commit 89e4b3bbc1
4 files changed
+99 -3

No files matched your search

+71
View File
@@ -130,6 +130,76 @@ async function searchInsets(p) {
if (delta !== null) expect(delta).toBeLessThanOrEqual(1);
}
}
async function groupWidths(browser) {
for (const width of [1180, 1470, 1920, 2560])
for (const locale of ['en', 'zh-TW']) {
const p = await browser.newPage({viewport: {width, height: 900}, locale, reducedMotion: 'reduce', colorScheme: 'dark'});
p.setDefaultTimeout(15000);
await p.addInitScript(locale => {
localStorage.setItem('doona-lite.locale', locale);
localStorage.setItem('doona-lite.theme', 'dark');
}, locale);
await p.goto(base);
await p.getByRole('button', {name: locale === 'en' ? 'Try the demo' : '試用示範', exact: true}).click();
await p.locator('[data-group-row]').first().waitFor();
await settle(p);
const rows = await p.locator('[data-group-row]:visible').evaluateAll(rows =>
rows.map(row => {
const box = row.getBoundingClientRect();
const walker = document.createTreeWalker(row, NodeFilter.SHOW_TEXT);
const texts = [];
while (walker.nextNode()) if (walker.currentNode.textContent.trim()) texts.push(walker.currentNode);
const nameElement = texts.find(node => node.textContent === row.dataset.groupRow).parentElement;
const name = nameElement.getBoundingClientRect();
const latency = texts.at(-1).parentElement;
return {
row: row.dataset.groupRow,
name: name.width,
fontSize: parseFloat(getComputedStyle(nameElement).fontSize),
nameInside: name.left >= box.left && name.right <= box.right,
latency: latency.textContent,
latencyInside: latency.getBoundingClientRect().right <= box.right + 0.5 && latency.scrollWidth <= latency.clientWidth
};
})
);
expect(rows.length).toBeGreaterThan(0);
for (const row of rows) {
expect(row.name, JSON.stringify(row)).toBeGreaterThanOrEqual(4 * row.fontSize);
expect(row.nameInside && row.latencyInside, JSON.stringify(row)).toBe(true);
}
const insets = await p
.locator('nav')
.first()
.evaluate(nav => {
const box = nav.getBoundingClientRect();
const scrolled = [nav, ...nav.querySelectorAll('*')].filter(e => e.scrollLeft !== 0).length;
const items = [...nav.querySelectorAll('.astryx-side-nav-item')]
.filter(e => e.checkVisibility() && !e.parentElement.closest('.astryx-side-nav-item'))
.map(e => e.getBoundingClientRect());
return {scrolled, items: items.map(r => ({start: r.left - box.left, end: box.right - r.right}))};
});
expect(insets.scrolled).toBe(0);
expect(insets.items.length).toBeGreaterThan(0);
for (const item of insets.items) expect(Math.abs(item.start - item.end), JSON.stringify(insets)).toBeLessThanOrEqual(1);
await screenshot(p, `groups-${width}-${locale}-dark`);
if (width >= 1470) {
const inspector = p.getByLabel(locale === 'en' ? 'Group details' : '策略群組詳細資料', {exact: true});
const handle = p.getByRole('separator', {name: locale === 'en' ? 'Resize group details' : '調整策略群組詳細資料寬度', exact: true});
for (const [key, chosen] of [
[null, 640],
['Home', 480],
['End', 880]
]) {
if (key) await handle.press(key);
await expect(handle).toHaveAttribute('aria-valuenow', String(chosen));
expect((await inspector.boundingBox()).width).toBeCloseTo(chosen, 1);
}
console.log(`PASS inspector default and chosen widths: ${width} ${locale}`);
}
console.log(`PASS group names and sidebar inset: ${width} ${locale}`);
await p.close();
}
}
(async () => {
const browser = await chromium.launch();
try {
@@ -268,6 +338,7 @@ async function searchInsets(p) {
console.log(`PASS layout rhythm, md controls, single-line labels, insets and footer: ${width} ${locale}`);
await p.close();
}
await groupWidths(browser);
} finally {
await browser.close();
}
+23 -3
View File
@@ -43,7 +43,7 @@ import {useDraftGuard} from './ui/draftGuard';
import {EditDialog} from './ui/EditDialog';
import {policyLabel} from './ui/groupLabels';
import {Close, Search} from './ui/icons';
import {MEDIA} from './ui/metrics.stylex';
import {groupListMinRem, MEDIA} from './ui/metrics.stylex';
import {Crossfade, RowEntrance} from './ui/motion';
import {DraftPresence} from './ui/motion/DraftPresence';
import {revealRow} from './ui/motion/revealRow';
@@ -73,6 +73,7 @@ const dots: Record<GroupStatus, 'success' | 'warning' | 'error' | 'neutral'> = {
export function Groups({connection, setBusy}: {connection: Connection; setBusy: (busy: boolean) => void}) {
const t = useMessages();
const phone = useMediaQuery(MEDIA.phone);
const wide = useMediaQuery(MEDIA.wide);
const {api, capabilities} = connection;
const read = useRead(useCallback((signal?: AbortSignal) => readGroups(api, signal), [api]));
const resources = useRead(
@@ -126,7 +127,26 @@ export function Groups({connection, setBusy}: {connection: Connection; setBusy:
const [copyFrom, setCopyFrom] = useState<string | null>(null);
const [groupText, setGroupText] = useState<{name: string; duplicate: boolean} | null>(null);
const [pendingMember, setPendingMember] = useState<string | null>(null);
const panel = useResizable({defaultSize: 640, minSize: 480, maxSize: 880});
const [panelBounds, setPanelBounds] = useState({min: 480, max: 880});
const panel = useResizable({defaultSize: 640, minSize: wide ? 480 : panelBounds.min, maxSize: wide ? 880 : panelBounds.max});
const watchPanel = useCallback(
(node: HTMLDivElement | null) => {
if (!node || wide) return;
const row = node.parentElement!;
const update = () => {
const width = row.getBoundingClientRect().width;
if (!width) return;
const min = width * 0.45;
const listMin = groupListMinRem * parseFloat(getComputedStyle(document.documentElement).fontSize);
setPanelBounds({min, max: Math.min(880, Math.max(min, width - listMin))});
};
const observer = new ResizeObserver(update);
observer.observe(row);
update();
return () => observer.disconnect();
},
[wide]
);
const list = useRef<HTMLDivElement>(null);
const [reveal, setReveal] = useState<{name: string; added: boolean} | null>(null);
@@ -463,7 +483,7 @@ export function Groups({connection, setBusy}: {connection: Connection; setBusy:
phone ? undefined : (
<>
<ResizeHandle resizable={panel.props} isReversed isAlwaysVisible={false} label={t.resizeInspector} />
<LayoutPanel resizable={panel.props} hasDivider padding={0} label={t.groupDetails}>
<LayoutPanel ref={watchPanel} resizable={panel.props} hasDivider padding={0} label={t.groupDetails}>
<VStack gap={0} xstyle={styles.inspector}>
<CollectionLoading loading={!inspectorReady} name="group-inspector" prepared={expectedCount !== undefined}>
{showPlaceholder =>
+2
View File
@@ -5,6 +5,8 @@ export const geometry = stylex.defineVars({
settingsHeight: 'min(50rem, calc(100dvh - var(--spacing-8)))',
editorColumns: '15rem minmax(0, 1fr)'
});
// Room for list insets, a status dot, the policy, the latency and a name.
export const groupListMinRem = 22;
export const MEDIA = {
wide: '(min-width: 1280px)',
tablet: '(min-width: 768px)',
+3
View File
@@ -0,0 +1,3 @@
Fixed
- doona lite: at mid window widths the groups list keeps each group name beside the details panel, and the latency is no longer cut off.