gui: a redraw with no copy of the pressed element marks the focus it gives, as before 9dd7aabca
9dd7aabcastopped openModal's focus from marking the dialog's hold on every redraw, so a refresh pressed among alike rows stays held. In WebKit, which doesn't focus a button on click, that left the hold on a button the redraw took away (Codex's Sign out, then the ask's Cancel). holdModal then fell back to the focused element with the old element's depth (modalHold.y), moved the dialog by the difference, and its ResizeObserver reported a loop: codex-signout "webkit en: Codex's only account signs out, asked first" red 3 of 3, green 3 of 3 at its parenta6a99717e. Now the focus given back skips the mark only when there is a copy of the pressed element to hold (the element kept through the redraw, or the focused one of several alike); otherwise it marks it as before. Found by serving app.js with each part of9dd7aabcaturned off in turn: only the refocus guard took the red away. Core: 1,533,732 (budget 1,533,802), no raise. Run at this head, rebased onb8270850d(wsl-run, Linux, Playwright 1.62.0): - codex-signout, account-refresh-holds and builtin-places (main's new GUI file): 110 of 110 ok. - go test -tags nogui ./internal/gui -run 'Budget|I18n|Dates': ok. The whole package hit go test's 10m default on WSL; a 30m run is going. Before the rebase, ona6a99717e: - codex-signout.test.cjs, 3 times: 24 of 24 ok each time - account-refresh-holds.test.cjs and click-scroll.test.cjs: account-refresh-holds 4 of 4 ok; click-scroll ok but for its WebKit late-heard wheel (#4385) - go test -tags nogui ./internal/gui -run 'Budget|I18n|Dates': ok After9dd7aabca, the rest of the 203 GUI files that reach #modal ran to a 3600s cap; every other red there is red the same ata6a99717eand filed: model-chip-steady #4388, i18n-keys #5332, icon-url #4688, inner-scroll-contain #4689, menu-input-scroll #3402, mcp-hub-direct #4701, ledger-hscroll (red 2 of 3 ata6a99717etoo) #4400, click-scroll's late-heard wheel #4385. Not tried: the real Wails app.
This commit is contained in:
@@ -9002,10 +9002,11 @@ function openModal(content, quiet) {
|
||||
|| focusIndex >= 0 && content.querySelectorAll("input, textarea, select, button")[focusIndex];
|
||||
// the focus given back is not a press: what was pressed stays held, by
|
||||
// the element a redraw put back or by the focused copy of it
|
||||
modalRefocus = !fresh;
|
||||
const copy = held && (content.contains(held) ? held : held === active && focus) || null;
|
||||
modalRefocus = !!copy;
|
||||
try { (focus || content.querySelector("input:not([disabled]), textarea, select, button:not([disabled])") || d).focus(NO_SCROLL); }
|
||||
finally { modalRefocus = false; }
|
||||
if (held) modalHold.copy = content.contains(held) ? held : held === active && focus || null;
|
||||
modalHold.copy = copy;
|
||||
const body = content.querySelector(":scope > .ebody");
|
||||
if (body) body.scrollTop = top; // a re-render keeps the place
|
||||
const nextNames = content.querySelector(".mnames:not([hidden])");
|
||||
|
||||
Reference in New Issue
Block a user