Skip to content

Commit a89c568

Browse files
authored
fix(ui): center dashboard widget controls on hover (#126076)
* fix(ui): center dashboard widget hover controls * fix(ui): gate resize handle with centered hover * fix(ui): preserve iframe clicks with centered controls * fix(ui): preserve corner actions when centering controls * fix(ui): compact centered controls at intermediate widths * test(plugins): align SDK subpath docs contract wording
1 parent 4ffa2a4 commit a89c568

3 files changed

Lines changed: 47 additions & 29 deletions

File tree

‎src/plugins/contracts/plugin-sdk-subpaths.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ describe("plugin-sdk subpath exports", () => {
496496
expect(docs).toContain("scripts/lib/plugin-sdk-entrypoints.json");
497497
expect(docs).toContain("scripts/lib/plugin-sdk-private-local-only-subpaths.json");
498498
expect(docs).toContain("scripts/lib/plugin-sdk-deprecated-public-subpaths.json");
499-
expect(docs).toContain("are labeled private-local below");
499+
expect(docs).toContain("selected private-local entries");
500500

501501
for (const subpath of pluginSdkSubpaths) {
502502
expect(packageExports).toHaveProperty(`./plugin-sdk/${subpath}`, {

‎ui/src/components/board/board-view.browser.test.ts‎

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,26 +127,31 @@ describe.skipIf(!hasBrowserLayout)("openclaw-board-view browser layout", () => {
127127

128128
it("reveals widget chrome while the widget has focus", async () => {
129129
const view = await mount();
130+
view.style.width = "1200px";
130131
const sink = focusSink();
131132
const widget = view.querySelector<HTMLElement>('[data-test-id="board-widget"]');
132133
const bar = widget!.querySelector<HTMLElement>(".board-widget__bar");
133134

134135
widget!.focus();
135136
expect(getComputedStyle(bar!).visibility).toBe("visible");
136-
// Chrome is a compact top-left pill, not a full-width strip: it must not
137-
// stretch across the card, so widget-owned top-right actions stay clear.
137+
// Chrome is a compact centered pill, not a full-width strip: it must not
138+
// stretch across the card, so widget-owned corner actions stay clear.
138139
const barBounds = bar!.getBoundingClientRect();
139140
const widgetBounds = widget!.getBoundingClientRect();
140141
expect(barBounds.width).toBeLessThan(widgetBounds.width * 0.75);
141-
expect(barBounds.left - widgetBounds.left).toBeLessThan(widgetBounds.right - barBounds.right);
142+
expect(barBounds.left + barBounds.width / 2).toBeCloseTo(
143+
widgetBounds.left + widgetBounds.width / 2,
144+
0,
145+
);
142146

143147
sink.focus();
144148
expect(widget!.matches(":focus-within")).toBe(false);
145149
await vi.waitFor(() => expectChromeHidden(widget!, bar!));
146150
});
147151

148-
it("reserves the top-right action corner even for narrow long-titled widgets", async () => {
152+
it("compacts centered chrome at intermediate widths", async () => {
149153
const view = await mount();
154+
view.style.width = "700px";
150155
view.snapshot = {
151156
...structuredClone(source),
152157
widgets: [
@@ -165,10 +170,19 @@ describe.skipIf(!hasBrowserLayout)("openclaw-board-view browser layout", () => {
165170
const bar = widget!.querySelector<HTMLElement>(".board-widget__bar");
166171
widget!.focus();
167172
expect(getComputedStyle(bar!).visibility).toBe("visible");
168-
// The interactive pill reserves a widget-owned right-hand region and none
169-
// of its children may overflow the capped box into that corner.
170173
const widgetBounds = widget!.getBoundingClientRect();
171-
expect(widgetBounds.right - bar!.getBoundingClientRect().right).toBeGreaterThanOrEqual(88);
174+
const barBounds = bar!.getBoundingClientRect();
175+
expect(widgetBounds.width).toBeGreaterThan(264);
176+
expect(widgetBounds.width).toBeLessThanOrEqual(376);
177+
expect(barBounds.left + barBounds.width / 2).toBeCloseTo(
178+
widgetBounds.left + widgetBounds.width / 2,
179+
0,
180+
);
181+
expect(barBounds.left - widgetBounds.left).toBeGreaterThanOrEqual(88);
182+
expect(widgetBounds.right - barBounds.right).toBeGreaterThanOrEqual(88);
183+
for (const selector of [".board-widget__title", ".board-widget__kind"]) {
184+
expect(getComputedStyle(bar!.querySelector<HTMLElement>(selector)!).display).toBe("none");
185+
}
172186
for (const child of bar!.children) {
173187
expect(child.getBoundingClientRect().right).toBeLessThanOrEqual(
174188
bar!.getBoundingClientRect().right + 1,
@@ -196,15 +210,17 @@ describe.skipIf(!hasBrowserLayout)("openclaw-board-view browser layout", () => {
196210
const bar = widget!.querySelector<HTMLElement>(".board-widget__bar");
197211
widget!.focus();
198212
expect(getComputedStyle(bar!).visibility).toBe("visible");
199-
// Below the 184px container threshold the display-only pieces disappear so
200-
// the pill is the irreducible move + menu pair and the rest of the card
201-
// stays widget-owned.
213+
// Very narrow cards keep the irreducible move + menu pair while the rest of
214+
// the card stays widget-owned.
202215
expect(widget!.getBoundingClientRect().width).toBeLessThan(184);
203216
const title = bar!.querySelector<HTMLElement>(".board-widget__title");
204217
const kind = bar!.querySelector<HTMLElement>(".board-widget__kind");
205218
expect(getComputedStyle(title!).display).toBe("none");
206219
expect(getComputedStyle(kind!).display).toBe("none");
207-
expect(bar!.getBoundingClientRect().width).toBeLessThanOrEqual(76);
220+
const widgetBounds = widget!.getBoundingClientRect();
221+
const barBounds = bar!.getBoundingClientRect();
222+
expect(barBounds.width).toBeLessThanOrEqual(76);
223+
expect(barBounds.left - widgetBounds.left).toBeLessThan(widgetBounds.right - barBounds.right);
208224
});
209225

210226
it("keeps widget chrome visible while its menu is open", async () => {

‎ui/src/styles/board.css‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -605,29 +605,24 @@ openclaw-workboard-board-widget {
605605
grid-template-rows: minmax(0, 1fr);
606606
}
607607

608-
/* Chrome is a compact top-left pill, not a full-width strip: widgets put
609-
their own actions top-right, so that corner must stay visible and
610-
clickable even while host chrome is revealed. The 30px pill height is
611-
overlay-only; coarse pointers keep the base 38px in-flow grid row that
612-
BOARD_WIDGET_TOUCH_BAR_PX mirrors. */
608+
/* Fine pointers center a compact overlay; coarse pointers keep the base 38px
609+
in-flow row that BOARD_WIDGET_TOUCH_BAR_PX mirrors. */
613610
.board-widget__bar {
614611
backdrop-filter: blur(6px);
615612
background: color-mix(in srgb, var(--board-surface) 92%, transparent);
616613
border: 1px solid var(--board-line);
617614
border-radius: 999px;
618615
box-shadow: 0 4px 14px rgb(0 0 0 / 18%);
619616
height: 30px;
620-
left: 7px;
621-
/* Reserve a widget-owned top-right action region: the interactive pill may
622-
never stretch across the card, or it re-intercepts the exact corner this
623-
chrome exists to keep clickable. The 88px floor keeps the drag handle and
624-
menu usable on very narrow widgets; below 184px the container query strips
625-
the pill to that irreducible pair so the reservation stays maximal. */
626-
max-width: max(88px, calc(100% - 96px));
617+
left: 50%;
618+
/* Centered widgets reserve 88px for actions in both top corners. Narrow
619+
cards fall back to the prior left placement below. */
620+
max-width: calc(100% - 176px);
627621
opacity: 0;
628622
padding: 0 5px;
629623
position: absolute;
630624
top: 7px;
625+
transform: translateX(-50%);
631626
transition:
632627
opacity 100ms ease,
633628
visibility 0s linear 100ms;
@@ -652,11 +647,18 @@ openclaw-workboard-board-widget {
652647
overflow: hidden;
653648
}
654649

655-
/* Below 184px the 96px reservation and the 88px pill cannot coexist, so the
656-
pill sheds its display-only pieces and keeps just move + menu — the two
657-
controls without which a widget cannot be managed. The card's aria-label
658-
and the drag handle tooltip still carry the title. */
659-
@container (max-width: 184px) {
650+
@container (max-width: 264px) {
651+
.board-widget__bar {
652+
left: 7px;
653+
max-width: max(88px, calc(100% - 96px));
654+
transform: none;
655+
}
656+
}
657+
658+
/* Until centered chrome has room for its display fields, keep only move +
659+
menu — the controls required to manage a widget. The card's aria-label and
660+
drag handle tooltip still carry the title. */
661+
@container (max-width: 376px) {
660662
.board-widget__bar > .board-widget__title,
661663
.board-widget__bar > .board-widget__kind,
662664
.board-widget__bar > .board-widget__capabilities {

0 commit comments

Comments
 (0)