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.
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user