gui: a scroll not the reader's made just before a click is put back, not kept as where the reader was (#1554)
skill-install-agents-all.test.cjs was red on main in Chromium at 420px (en, ja, de): the install picker's All chip, clicked, left the Library view 5px down. Cause: the browser tells the page of a scroll at the next frame. The test clicks while the Library view is still sliding in (view-in, translateY 5px), and Playwright's click scrolls the chip into view first; with the view 5px taller than it is high at 420px, that scroll takes the view to its 5px foot. The click came in before that scroll's event, so the click guard took its snapshot (held.chain, held.top) at 5px and every hold() after kept it there, the scroll event included. A real click can do the same: WebKit scrolls a field focused on the press, or code scrolls just before the click, and the scroll was adopted as the reader's. Fix (app.js, the click guard): before taking a click's snapshot, a view not scrolled by the reader (no purposeUntil window, no scrollbar drag) is put back where the reader left it (backToReader), as the scroll listener would have done a frame later. A click in quick turn after another still holds that one first, as before. The guard is shared by every view, so every picker and button is covered; the library picker needs no change of its own (the MCP editor's picker is in #modal, outside any view). Tests: - click-scroll.test.cjs: new "a scroll the page hears of after the click is still put back" (scrollTop += 40 and a click in one task). Red on the old app.js in Chromium and WebKit (expected 2020, actual 2060), green with the fix. - sessions-manage-paging.test.cjs scrolled with Playwright's scrollIntoViewIfNeeded and clicked Show more before the next frame, so it passed in Chromium only through this bug (the guard puts that scroll back a frame later; it was red in WebKit on main). It now scrolls with the reader's wheel; green in both engines. - docs/subsystems/gui-shell.md says a click is taken where the reader left the view. Run: skill-install-agents-all.test.cjs red before (en/ja/de 420px, "view:5,0"), green after in Chromium and WebKit, every language; click-scroll.test.cjs green in both engines; 306 GUI test files that assert on scrolling or touch the library/skills/MCP, then the other 253, both engines. Failures seen there were rerun alone: purpose-filter (WebKit, 1px, #1291) and search-api (WebKit zh, #1442) fail the same on the old app.js; the rest pass alone. No Go changed.
This commit is contained in:
@@ -148,7 +148,7 @@ retry after a failed read. See `TestRecentCallBodiesOnDemand` and
|
||||
|
||||
- Settings' search-provider picker offers **Off**, saved as `searcher: "off"`. Its help explains API-only search and suppresses provider fallback/own-search hints while off; the search priority row is hidden because no provider competes with the APIs. See [gateway search behavior](gateway-routing.md#turning-provider-search-off), [`renderSearcher`](../../internal/gui/assets/app.js), `TestSettingsSearchProviderOff` and `searcher-pick.test.cjs`.
|
||||
- Every user-visible string has zh, zh-TW, ja and de translations with the same placeholders. `gui-zh-tw.test.cjs`, `gui-ja.test.cjs` and `gui-de.test.cjs` fail on a missing one; `gui-zh-tw.test.cjs` also fails on a zh-TW string with a Simplified character left in it.
|
||||
- A click never moves the page. Code scrolls a view only with the reader's event in hand (`scrollOnPurpose`); `click-scroll.test.cjs` guards this.
|
||||
- A click never moves the page. Code scrolls a view only with the reader's event in hand (`scrollOnPurpose`); `click-scroll.test.cjs` guards this. A click is taken where the reader left the view: a scroll not theirs made just before it, whose scroll event the browser sends only at the next frame, after the click, is put back first (`backToReader` in the click guard, #1554).
|
||||
- There are no native `<select>` elements and no colored left-border stripes. State is shown with a dot or a swatch.
|
||||
- The Usage page's cards and the tray panel's Allowances tab share one order, `settings.UsageOrder` (`byUsageOrder`). In the panel a balance-only card stands where that order puts it, and balances next to each other share one *Balances* grid (`panelBalances`, #1510); none is gathered after the plans. The panel's *Arrange* (`panelArrange`) moves rows in it and hides subscriptions from that tab alone (`settings.PanelUsageHidden`); both save through `POST /api/usage/arrange`, which changes only the field it is sent, and the Settings save keeps both. Hiding is display only: a menu bar cell's card shows though hidden (`panelPeek`). See `TestUsageArrangePanelHidden`, `panel-arrange.test.cjs` and `panel-balance-order.test.cjs`.
|
||||
- The Usage page's cards are packed into columns, never stretched to a row's height (`packUsage`, #860): each card in that order goes to the leftmost column that ends highest, on 1px grid rows, so short cards stack beside a tall one. The page's order (DOM, dragging, Alt+arrows) stays `UsageOrder`. The column count is the most 260px columns that fit, or one fewer when that leaves much less empty room; it is chosen again only when the cards change or the width fits another number of columns, so a card opened or folded stays where it is, even as the scrollbar comes in. See `usage-pack.test.cjs`.
|
||||
|
||||
@@ -21769,6 +21769,7 @@ function keepHeld() {
|
||||
requestAnimationFrame(keepHeld);
|
||||
}
|
||||
addEventListener("click", (e) => {
|
||||
const readers = performance.now() < purposeUntil;
|
||||
purposeUntil = flingUntil = 0; // what came before the click (Space pressed on a button, a tremble, the lift of a tap) is no scroll
|
||||
// a pick in a menu (in body, outside any view) is a click on the pill that
|
||||
// opened it: what it changes comes in around that pill, which stays put (#961)
|
||||
@@ -21777,8 +21778,15 @@ addEventListener("click", (e) => {
|
||||
if (!v || v.hidden) { held = null; return; }
|
||||
// a click before a frame has held the one before it (a tab list's keys
|
||||
// pressed in quick turn) holds that one first: the page it shrank is put
|
||||
// back, so this one is taken where the reader left it, not at the top
|
||||
// back, so this one is taken where the reader left it, not at the top.
|
||||
// So is a scroll the page hasn't heard of yet: the browser tells of a
|
||||
// scroll at the next frame, and a scroll made just before the click and
|
||||
// not the reader's (a field focused on the press, scrolled to; a scroll by
|
||||
// code; a test's click scrolling what it clicks into view while the view
|
||||
// slides in) would be heard of only after it, and kept as where the reader
|
||||
// was (#1554).
|
||||
if (held?.v === v) hold(held);
|
||||
else if (!readers && barDrag !== v) backToReader(v);
|
||||
const chain = [];
|
||||
const from = at.closest?.("[data-unrolls]")?.parentElement || at;
|
||||
for (let n = from; n && n !== v; n = n.parentElement) {
|
||||
|
||||
@@ -185,6 +185,27 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
}
|
||||
});
|
||||
|
||||
// The browser tells of a scroll at the next frame. A scroll by code made
|
||||
// just before a click, and heard of only after it, was kept as where the
|
||||
// reader was (#1554: Playwright's click scrolled the skill picker's chip
|
||||
// into view while the view slid in, and the view stayed 5px down).
|
||||
await t.test("a scroll the page hears of after the click is still put back", async () => {
|
||||
await reset();
|
||||
await page.locator(view).evaluate((v) => {
|
||||
const s = document.createElement("div");
|
||||
s.style.cssText = "flex:none;height:1600px";
|
||||
const b = document.createElement("button");
|
||||
b.id = "late"; b.textContent = "late"; b.style.flex = "none";
|
||||
v.append(s, b, Object.assign(document.createElement("div"), { style: "flex:none;height:600px" }));
|
||||
});
|
||||
await scrollTo("#late");
|
||||
const was = await page.locator(view).evaluate((v) => v.scrollTop);
|
||||
// the scroll and the click in one task: no frame between them
|
||||
await page.locator(view).evaluate((v) => { v.scrollTop += 40; document.querySelector("#late").click(); });
|
||||
await settle(page);
|
||||
assert.equal(await page.locator(view).evaluate((v) => v.scrollTop), was, "the scroll before the click must be put back");
|
||||
});
|
||||
|
||||
await t.test("a control under what it unrolls goes down with it", async () => {
|
||||
await reset();
|
||||
await page.locator(view).evaluate((v) => {
|
||||
|
||||
@@ -75,7 +75,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert(box.x >= 0 && box.x + box.width <= width, `${width}px: Show more fits`);
|
||||
|
||||
// the next page goes under the rows drawn; they and the scroll stay
|
||||
await rows.nth(99).scrollIntoViewIfNeeded();
|
||||
// the reader scrolls there: a scroll by code (scrollIntoViewIfNeeded)
|
||||
// is put back at the next frame, and a click before that frame now
|
||||
// puts it back too (#1554)
|
||||
await page.mouse.move(width / 2, 320);
|
||||
const inSight = () => rows.nth(99).evaluate((e) => { const r = e.getBoundingClientRect(); return r.top >= 0 && r.bottom <= innerHeight; });
|
||||
for (let i = 0; i < 300 && !(await inSight()); i++) await page.mouse.wheel(0, 200);
|
||||
await page.waitForTimeout(300);
|
||||
assert(await inSight(), "the reader's wheel brings the last row drawn into sight");
|
||||
await rows.first().evaluate((e) => { e.kept = true; });
|
||||
const y = () => rows.nth(99).evaluate((e) => Math.round(e.getBoundingClientRect().top));
|
||||
const before = await y();
|
||||
|
||||
Reference in New Issue
Block a user