From 7e22bea680b57c4224854f8cb1125242bb335c16 Mon Sep 17 00:00:00 2001 From: yunyaozhou Date: Tue, 18 Aug 2026 11:49:35 +0800 Subject: [PATCH] fix: make one-line extension widgets expandable --- components/ExtensionWidgets.test.mjs | 21 +++++++++++++++++---- components/ExtensionWidgets.tsx | 4 ++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/components/ExtensionWidgets.test.mjs b/components/ExtensionWidgets.test.mjs index e1783aa73..c60851253 100644 --- a/components/ExtensionWidgets.test.mjs +++ b/components/ExtensionWidgets.test.mjs @@ -126,9 +126,9 @@ test("compares widget lines without delimiter collisions", () => { assert.deepEqual(getUpdatedExtensionWidgetKeys(previous, next), ["status"]); }); -test("uses a compact key-only trigger with a placement icon", () => { +test("keeps one-line widgets compact but expandable", () => { const html = renderWidgets({ - widgets: [{ key: "long-extension-widget-key", lines: ["ready"], placement: "belowEditor" }], + widgets: [{ key: "single-line-widget", lines: ["ready"], placement: "belowEditor" }], }); assert.match(html, /extension-widget-triggers/); @@ -136,11 +136,24 @@ test("uses a compact key-only trigger with a placement icon", () => { assert.match(html, /data-direction="down"/); assert.doesNotMatch(html, /[\u2191\u2193]/); assert.match(html, /Below editor widget/); - assert.doesNotMatch(html, /aria-expanded/); - assert.match(html, /title="long-extension-widget-key - Below editor widget"/); + assert.match(html, /]*class="extension-widget-trigger/); + assert.match(html, /aria-expanded="false"/); + assert.match(html, /title="single-line-widget - Below editor widget - Expand"/); assert.match(html, /extension-widget-key/); assert.match(html, /extension-widget-update-pulse/); assert.doesNotMatch(html, /extension-widget-preview/); assert.doesNotMatch(html, /extension-widget-line-count/); assert.doesNotMatch(html, />ready { + const html = renderWidgets({ + widgets: [{ key: "empty-widget", lines: [], placement: "aboveEditor" }], + }); + + assert.match(html, /
( widget.key === expandedWidgetKey - && widget.lines.length > 1 + && widget.lines.length > 0 )); const toggleWidget = (widget: ExtensionWidgetItem) => { @@ -139,7 +139,7 @@ export function ExtensionWidgets({ widgets }: { widgets: ExtensionWidgetItem[] } )}
{widgets.map((widget, index) => { - const expandable = widget.lines.length > 1; + const expandable = widget.lines.length > 0; const expanded = expandable && widget.key === expandedWidget?.key; const updating = updatingWidgetKeys.has(widget.key); const lineCountLabel = t(