Skip to content

Commit 40ce1b0

Browse files
committed
fix: keep sidebar visible while popups/context menus are open
Track popupshown/popuphidden events to guard compact mode from hiding the sidebar when a context menu or panel is open. Replaces the legacy CSS :has() selector chains with a simple ref-counted JS approach. Closes #30
1 parent de81557 commit 40ce1b0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

chrome/JS/palefox-drawer.uc.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,23 @@
195195
// Zen uses ZenHasPolyfill MutationObserver for [open], [panelopen],
196196
// [breakout-extend] — we use querySelector which is simpler and
197197
// sufficient for our single-element case.
198+
// 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.
201+
let _openPopups = 0;
202+
document.addEventListener("popupshown", () => _openPopups++);
203+
document.addEventListener("popuphidden", () => {
204+
_openPopups = Math.max(0, _openPopups - 1);
205+
});
206+
198207
function isGuarded() {
208+
// A popup/context menu is open
209+
if (_openPopups > 0) return true;
199210
// Urlbar autocomplete dropdown is open — hiding would break UX
200211
if (urlbar?.hasAttribute("breakout-extend")) return true;
201212
// A toolbar button menu is open (e.g. hamburger, extensions)
202213
if (document.querySelector("toolbarbutton[open='true']")) return true;
203214
// Tabs are being multi-selected or dragged
204-
// (Zen uses _isTabBeingDragged flag set by their drag handler —
205-
// we can't hook into that, so querySelector is our equivalent)
206215
if (document.querySelector(".tabbrowser-tab[multiselected]")) return true;
207216
return false;
208217
}
@@ -516,7 +525,7 @@
516525
const isCompact = sidebarMain.hasAttribute("data-pfx-compact");
517526
compactItem.setAttribute(
518527
"label",
519-
isCompact ? "Turn Compact Off" : "Turn Compact On"
528+
isCompact ? "Disable Compact" : "Enable Compact"
520529
);
521530
// Force-show native sidebar items Firefox hid for our button
522531
if (customizeSidebar) customizeSidebar.hidden = false;

0 commit comments

Comments
 (0)