profiles: Apply closes a profile's details, and their × closes them after it (#489, a regression of #478) — on Apply, profileAction dropped profileOpen and then called closeProfiles, whose closeProfileDetail, finding nothing open, returned at once; renderAgents had just drawn the details again, so they stayed in the window and came back with the tray's list, and their ×, which calls the same closeProfileDetail, did nothing until the chip was clicked again. Apply now closes the details itself, and closeProfileDetail closes details on the page whether or not profileOpen still names them. profile-confirm.test.cjs (Chromium, WebKit; en, zh; window and tray) now applies a profile from its details and checks they close, the tray's list opens again on the chips, and × closes them after it; it fails without the change. profile-details, panel-profiles, click-scroll, old-webkit pass; go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build pass.

This commit is contained in:
yetone committed 2026-10-02 08:20:32 +08:00
1 parent 480df9bac0
commit dfc8ea4aea
3 files changed
+33 -4

No files matched your search

+6 -2
View File
@@ -585,8 +585,9 @@ function toggleProfile(chip, p) {
}
// closeProfileDetail closes the details shown, if any: false if none were.
// Details on the page close whether or not profileOpen still names them.
function closeProfileDetail() {
if (!profileOpen) return false;
if (!profileOpen && !$("#profiles > .prof-detail")) return false;
profileOpen = null;
$("#profiles > .prof-detail")?.remove();
$(".profiles").classList.remove("detailed");
@@ -2511,7 +2512,10 @@ async function profileAction(action, name, update) {
state = data;
renderAgents();
if (action === "use") {
profileOpen = null;
// the details close, renderAgents having drawn them again (#489:
// profileOpen dropped first, closeProfileDetail found nothing open and
// left them there, their × doing nothing)
closeProfileDetail();
closeProfiles(); // the agents, as they are now, in sight
let msg = t(data.changed === 1 ? "{name} applied · {n} setting changed" : "{name} applied · {n} settings changed", { name, n: data.changed });
const lib = data.library;
+3 -2
View File
@@ -357,8 +357,9 @@ chip's ↻ and × change nothing on a first click, reading "Overwrite?" and
"Delete?" instead, and act on a second; the question goes on Escape or when
left alone. The details' × closes them, the chip staying where it is; Escape
closes the details, then the panel's list, and only then hides the panel;
the list closed with the details open opens again on the chips alone, as
after Apply. In Chromium and WebKit, English and Chinese:
the list closed with the details open opens again on the chips alone; Apply
closes the details, the tray's list opening again on the chips, and their ×
closes them after it (#489). In Chromium and WebKit, English and Chinese:
```sh
node --test --test-concurrency=1 internal/gui/tests/profile-details.test.cjs internal/gui/tests/panel-profiles.test.cjs internal/gui/tests/profile-confirm.test.cjs
@@ -163,6 +163,30 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await detail.count(), 0, "closed with the list, the details stay closed");
assert.equal(await home.getAttribute("aria-expanded"), "false");
} else assert.deepEqual(calls, []);
// Apply closes the details, for good, and × works after it (#489:
// the details stayed, or came back with the list, and their × did
// nothing)
calls.length = 0; // in the panel, the list is open from above
await homeName.click();
await detail.waitFor();
await detail.locator(".pd-apply").click();
await page.waitForFunction(() => document.querySelector("#status").classList.contains("ok"));
assert.deepEqual(calls, ["use home"]);
await page.waitForTimeout(200);
assert.equal(await detail.count(), 0, "Apply closes the details");
assert.equal(await home.getAttribute("aria-expanded"), "false");
if (panel) {
assert.equal(await open.count(), 0, "Apply closes the panel's list");
await openList();
assert.equal(await detail.count(), 0, "after Apply the list opens on the chips");
}
await homeName.click();
await detail.waitFor();
await detail.locator(".pd-close").click();
await page.waitForTimeout(200);
assert.equal(await detail.count(), 0, "after Apply the details' × still closes them");
assert.equal(await home.getAttribute("aria-expanded"), "false");
assert.deepEqual(errors, []);
});
}