fix(clawsweeper): address review for automerge-openclaw-openclaw-75590 (1)

This commit is contained in:
clawsweeper
2026-05-03 02:10:43 +00:00
parent 175420b47f
commit 62240d8153
2 changed files with 18 additions and 1 deletions

View File

@@ -303,6 +303,14 @@ function openDeleteConfirm(deleteButton: HTMLButtonElement) {
deleteButton.dispatchEvent(new MouseEvent("click", { bubbles: true }));
}
function clickDeleteButtonIconPath(deleteButton: HTMLButtonElement) {
const icon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
icon.appendChild(path);
deleteButton.appendChild(icon);
path.dispatchEvent(new MouseEvent("click", { bubbles: true }));
}
function setupArmedDeleteConfirm() {
const flushAnimationFrames = stubAnimationFrameQueue();
const addListenerSpy = vi.spyOn(document, "addEventListener");
@@ -455,6 +463,15 @@ describe("grouped chat rendering", () => {
expect(fixture.onDelete).not.toHaveBeenCalled();
});
it("removes the delete confirm outside-click listener when the delete button icon toggles it", () => {
const fixture = setupArmedDeleteConfirm();
clickDeleteButtonIconPath(fixture.deleteButton);
expectDeleteConfirmDismissed(fixture);
expect(fixture.onDelete).not.toHaveBeenCalled();
});
it("does not attach the delete confirm outside-click listener after an immediate toggle", () => {
const flushAnimationFrames = stubAnimationFrameQueue();
const addListenerSpy = vi.spyOn(document, "addEventListener");

View File

@@ -676,7 +676,7 @@ function renderDeleteButton(onDelete: () => void, side: DeleteConfirmSide) {
}
function closeOnOutside(evt: MouseEvent) {
const target = evt.target;
if (target instanceof Node && !popover.contains(target) && target !== btn) {
if (target instanceof Node && !popover.contains(target) && !btn.contains(target)) {
dismissPopover();
}
}