Skip to content

Commit 8be20aa

Browse files
committed
dnd: Fix tooltip overlap with DND duration dropdown and auto-hide on mouse leave.
Prevents the tooltip from obscuring the dropdown and improves UX by closing the dropdown when the cursor leaves the area.
1 parent 53e5631 commit 8be20aa

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

app/main/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ function createMainWindow(): BrowserWindow {
412412
) => {
413413
if (listener === "toggle-dnd-request") {
414414
const [duration] = parameters as [number?];
415-
const result = DNDUtil.toggle(); // Toggle DND
415+
const result = DNDUtil.toggle();
416416
send(event.sender, "toggle-dnd", result.dnd, result.newSettings);
417417

418418
if (result.dnd && duration && !Number.isNaN(duration)) {
@@ -425,6 +425,9 @@ function createMainWindow(): BrowserWindow {
425425
},
426426
duration * 60 * 1000,
427427
);
428+
} else if (dndRevertTimeout) {
429+
clearTimeout(dndRevertTimeout);
430+
dndRevertTimeout = null;
428431
}
429432

430433
return;

app/renderer/js/main.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,18 @@ export class ServerManagerView {
443443

444444
initLeftSidebarEvents(): void {
445445
this.$dndButton.addEventListener("click", () => {
446+
const isDndOn = ConfigUtil.getConfigItem("dnd", false);
447+
if (isDndOn) {
448+
ipcRenderer.send("forward-message", "toggle-dnd-request", undefined);
449+
return;
450+
}
451+
446452
const dropdown = document.querySelector("#dnd-dropdown");
447453
dropdown?.classList.toggle("hidden");
448454
this.$dndTooltip.classList.add("hidden");
455+
dropdown?.addEventListener("mouseleave", () => {
456+
dropdown.classList.add("hidden");
457+
});
449458
});
450459
const dropdownItems = document.querySelectorAll("#dnd-dropdown div");
451460
for (const item of dropdownItems) {
@@ -457,6 +466,7 @@ export class ServerManagerView {
457466
ipcRenderer.send("forward-message", "toggle-dnd-request", duration);
458467

459468
document.querySelector("#dnd-dropdown")?.classList.add("hidden");
469+
this.$dndTooltip.classList.remove("hidden");
460470
});
461471
}
462472

0 commit comments

Comments
 (0)