Skip to content

Commit 29fc91f

Browse files
fix(ui): balance side panel tab pill padding (#125368)
Fixes crowded side-panel tab close padding and keeps the joined pill balanced in LTR and RTL. Co-authored-by: Tak Hoffman <[email protected]>
1 parent 9f5776e commit 29fc91f

2 files changed

Lines changed: 73 additions & 7 deletions

File tree

‎ui/src/e2e/chat-sidebar-panel-contract.e2e.test.ts‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,62 @@ suite.define(() => {
291291
expect(await companionMenu.count()).toBe(1);
292292
expect(await contentActions.locator(":scope > button").count()).toBe(0);
293293

294+
const tab = page.locator(".side-panel__header .tabstrip-tab[active]");
295+
for (const direction of ["ltr", "rtl"] as const) {
296+
const tabPadding = await tab.evaluate((node, dir) => {
297+
const panel = node.closest(".side-panel");
298+
if (!(panel instanceof HTMLElement)) {
299+
throw new Error("Active side-panel tab must render inside the side panel");
300+
}
301+
panel.dir = dir;
302+
const tabBase = node.shadowRoot?.querySelector<HTMLElement>("[part~='base']");
303+
const leadingGlyph = node.querySelector<HTMLElement>(".tabstrip-tab__icon svg");
304+
const close = node.nextElementSibling;
305+
const trailingGlyph = close?.querySelector<HTMLElement>("svg");
306+
if (!(close instanceof HTMLElement) || !tabBase || !leadingGlyph || !trailingGlyph) {
307+
throw new Error("Active side-panel tab must render both edge glyphs");
308+
}
309+
const tabBounds = tabBase.getBoundingClientRect();
310+
const closeBounds = close.getBoundingClientRect();
311+
const leadingBounds = leadingGlyph.getBoundingClientRect();
312+
const trailingBounds = trailingGlyph.getBoundingClientRect();
313+
const rtl = dir === "rtl";
314+
const tabStyle = getComputedStyle(tabBase);
315+
const closeStyle = getComputedStyle(close);
316+
return {
317+
leading: rtl
318+
? tabBounds.right - leadingBounds.right
319+
: leadingBounds.left - tabBounds.left,
320+
trailing: rtl
321+
? trailingBounds.left - closeBounds.left
322+
: closeBounds.right - trailingBounds.right,
323+
tabOuterRadius: Number.parseFloat(
324+
rtl ? tabStyle.borderTopRightRadius : tabStyle.borderTopLeftRadius,
325+
),
326+
tabJoinRadius: Number.parseFloat(
327+
rtl ? tabStyle.borderTopLeftRadius : tabStyle.borderTopRightRadius,
328+
),
329+
closeJoinRadius: Number.parseFloat(
330+
rtl ? closeStyle.borderTopRightRadius : closeStyle.borderTopLeftRadius,
331+
),
332+
closeOuterRadius: Number.parseFloat(
333+
rtl ? closeStyle.borderTopLeftRadius : closeStyle.borderTopRightRadius,
334+
),
335+
};
336+
}, direction);
337+
expect(tabPadding.trailing, `${direction} glyph insets`).toBeCloseTo(tabPadding.leading, 0);
338+
expect(tabPadding.tabJoinRadius, `${direction} tab join`).toBe(0);
339+
expect(tabPadding.closeJoinRadius, `${direction} close join`).toBe(0);
340+
expect(tabPadding.tabOuterRadius, `${direction} tab outer`).toBeGreaterThan(0);
341+
expect(tabPadding.closeOuterRadius, `${direction} close outer`).toBeGreaterThan(0);
342+
}
343+
await tab.evaluate((node) => {
344+
const panel = node.closest(".side-panel");
345+
if (panel instanceof HTMLElement) {
346+
panel.removeAttribute("dir");
347+
}
348+
});
349+
294350
await page.locator(".side-panel-type-menu__trigger").click();
295351
await page.locator(".side-panel-type-menu__item").filter({ hasText: "Discussion" }).click();
296352
const discussionAction = contentActions.locator(

‎ui/src/styles/chat/sidebar.css‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ openclaw-chat-sidebar-region,
427427
align-items: center;
428428
justify-content: flex-start;
429429
gap: 7px;
430-
padding: 0 8px;
430+
padding-inline: 8px 0;
431431
border: 0;
432432
border-radius: var(--radius-md);
433433
background: transparent;
@@ -439,15 +439,22 @@ openclaw-chat-sidebar-region,
439439
color 120ms ease;
440440
}
441441

442+
.side-panel__header
443+
.tabstrip-tab:not([active]):is(:hover, :has(+ .tabstrip-tab__close:hover))::part(base),
444+
.side-panel__header .tabstrip-tab[active]::part(base) {
445+
border-start-start-radius: var(--radius-md);
446+
border-end-start-radius: var(--radius-md);
447+
border-start-end-radius: 0;
448+
border-end-end-radius: 0;
449+
}
450+
442451
.side-panel__header
443452
.tabstrip-tab:not([active]):is(:hover, :has(+ .tabstrip-tab__close:hover))::part(base) {
444-
border-radius: var(--radius-md) 0 0 var(--radius-md);
445453
background: color-mix(in srgb, var(--text) 5%, transparent);
446454
color: var(--text);
447455
}
448456

449457
.side-panel__header .tabstrip-tab[active]::part(base) {
450-
border-radius: var(--radius-md) 0 0 var(--radius-md);
451458
background: var(--bg-hover);
452459
color: var(--text);
453460
}
@@ -510,13 +517,16 @@ openclaw-chat-sidebar-region,
510517
}
511518

512519
.side-panel__header .tabstrip-tab__close {
513-
width: 16px;
514-
min-width: 16px;
520+
width: 28px;
521+
min-width: 28px;
515522
height: 28px;
516-
flex: 0 0 16px;
523+
flex: 0 0 28px;
517524
align-self: center;
518525
margin: 0;
519-
border-radius: 0 var(--radius-md) var(--radius-md) 0;
526+
border-start-start-radius: 0;
527+
border-end-start-radius: 0;
528+
border-start-end-radius: var(--radius-md);
529+
border-end-end-radius: var(--radius-md);
520530
opacity: 0;
521531
transition:
522532
background-color 120ms ease,

0 commit comments

Comments
 (0)