From 5710283da5c7cf05a65bfc56a5e83580c43fc9d0 Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 11 Nov 2026 17:23:28 +0800 Subject: [PATCH] settings: a hint card's text lines up with the row's name (mmmg_btc on X) The hover card sat with its box edge at the name's left, so its text started 11px (the card's padding) right of the label. show() now shifts the card left by its padding, so text and name share an edge. Editor fields, Routing's .hint-row and the account-switch hint go through the same function. A row with no name keeps the card's edge at the row's edge. settings-hints asserts the text's x against the name's: red on origin/main (254 vs 243 at 1100, 35 vs 31 at 420), green with the change, en/zh/zh-TW/ ja/de at 1100 and 420, chromium. Ran settings-hints, editor-hints, provider-prefs-layout, settings-lines-wrap, sign-in-moves, searcher-pick, i18n-keys in both engines: the only reds are the ones origin/main has (editor-hints in WebKit; settings-hints ja/de at 420, #6107, #6073). Not tried: WebKitGTK. --- internal/gui/assets/settingshints.js | 8 ++++++-- internal/gui/tests/settings-hints.test.cjs | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/gui/assets/settingshints.js b/internal/gui/assets/settingshints.js index 310a0abe4..9e165f7cd 100644 --- a/internal/gui/assets/settingshints.js +++ b/internal/gui/assets/settingshints.js @@ -44,9 +44,13 @@ function show(r) { card.hidden = false; // a .who the editor lays out as display: contents has no box of its own: its name's stands for it const lead = r.querySelector(":scope > .who, :scope > .txt") || r; - const who = (getComputedStyle(lead).display === "contents" ? lead.querySelector(".name") || r : lead).getBoundingClientRect(), box = r.getBoundingClientRect(); + const at = getComputedStyle(lead).display === "contents" ? lead.querySelector(".name") || r : lead; + const who = at.getBoundingClientRect(), box = r.getBoundingClientRect(); const w = card.offsetWidth, h = card.offsetHeight; - const left = Math.max(16, Math.min(who.left, innerWidth - 16 - w)); + // the card's text, not its edge, lines up with the row's name (a row with + // no name of its own has the card's edge at its own) + const pad = at === r ? 0 : parseFloat(getComputedStyle(card).paddingLeft) || 0; + const left = Math.max(16, Math.min(who.left - pad, innerWidth - 16 - w)); // under the row, or over it where the window ends first const top = box.bottom + 4 + h <= innerHeight - 8 ? box.bottom + 4 : Math.max(8, box.top - 4 - h); card.style.left = left + "px"; diff --git a/internal/gui/tests/settings-hints.test.cjs b/internal/gui/tests/settings-hints.test.cjs index 2640ed08f..31e0faad0 100644 --- a/internal/gui/tests/settings-hints.test.cjs +++ b/internal/gui/tests/settings-hints.test.cjs @@ -120,6 +120,11 @@ for (const engine of engines) { const name = await mcp.locator(":scope > .who > .name").boundingBox(), cb = await card.boundingBox(); assert.ok(cb.y >= name.y + name.height || cb.y + cb.height <= name.y, "the card covers the row's name"); assert.ok(cb.x >= 15 && cb.x + cb.width <= width - 15, `the card runs out of the window: ${JSON.stringify(cb)}`); + // its text starts where the row's name does (11-11, mmmg_btc on X: "设置里面的提示也没有对齐"), + // where the window leaves room for the card's padding to the left of it + const line = await card.locator("p").first().boundingBox(); + if (name.x >= 16 + 12) assert.ok(Math.abs(line.x - name.x) <= 1, `the card's text is at x=${line.x}, the row's name at x=${name.x}`); + else assert.ok(line.x >= name.x - 1, `the card's text is at x=${line.x}, left of the row's name at x=${name.x}`); assert.deepEqual(await page.evaluate(boxes), before, "a row moved when the card showed"); assert.equal(await card.evaluate((e) => getComputedStyle(e).pointerEvents), "none");