mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:10:45 +00:00
fix(clawsweeper): address review for automerge-openclaw-openclaw-75590 (1)
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user