Skip to content

Commit 2860717

Browse files
committed
fix: sidebar stays visible during popups and after urlbar breakout
Guard compact mode hide with popup event tracking (menupopup/panel only). Re-trigger hide when urlbar breakout closes and mouse is outside the sidebar.
1 parent 40ce1b0 commit 2860717

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

chrome/JS/palefox-drawer.uc.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,22 +196,24 @@
196196
// [breakout-extend] — we use querySelector which is simpler and
197197
// sufficient for our single-element case.
198198
// Track open popups (context menus, panels) so compact mode doesn't
199-
// hide the sidebar while a menu is visible. Legacy CSS solved this with
200-
// enormous :has() selector chains; listening for popup events is cleaner.
199+
// hide the sidebar while a menu is visible. Only count XUL popups,
200+
// not HTML popovers like the urlbar's breakout.
201201
let _openPopups = 0;
202-
document.addEventListener("popupshown", () => _openPopups++);
203-
document.addEventListener("popuphidden", () => {
204-
_openPopups = Math.max(0, _openPopups - 1);
202+
document.addEventListener("popupshown", (e) => {
203+
if (e.target.localName === "menupopup" || e.target.localName === "panel") {
204+
_openPopups++;
205+
}
206+
});
207+
document.addEventListener("popuphidden", (e) => {
208+
if (e.target.localName === "menupopup" || e.target.localName === "panel") {
209+
_openPopups = Math.max(0, _openPopups - 1);
210+
}
205211
});
206212

207213
function isGuarded() {
208-
// A popup/context menu is open
209214
if (_openPopups > 0) return true;
210-
// Urlbar autocomplete dropdown is open — hiding would break UX
211215
if (urlbar?.hasAttribute("breakout-extend")) return true;
212-
// A toolbar button menu is open (e.g. hamburger, extensions)
213216
if (document.querySelector("toolbarbutton[open='true']")) return true;
214-
// Tabs are being multi-selected or dragged
215217
if (document.querySelector(".tabbrowser-tab[multiselected]")) return true;
216218
return false;
217219
}
@@ -323,6 +325,12 @@
323325
urlbar.showPopover();
324326
} else {
325327
urlbar.removeAttribute("popover");
328+
// Breakout closed — if mouse isn't over the sidebar, hide it.
329+
// Fixes: click urlbar → click away → sidebar stays stuck visible
330+
// (the earlier mouseleave was blocked by the breakout guard).
331+
if (!sidebarMain.matches(":hover")) {
332+
flashSidebar(KEEP_HOVER_DURATION);
333+
}
326334
}
327335
}).observe(urlbar, { attributes: true, attributeFilter: ["breakout-extend"] });
328336
}

0 commit comments

Comments
 (0)