|
195 | 195 | // Zen uses ZenHasPolyfill MutationObserver for [open], [panelopen], |
196 | 196 | // [breakout-extend] — we use querySelector which is simpler and |
197 | 197 | // 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 | + |
198 | 207 | function isGuarded() { |
| 208 | + // A popup/context menu is open |
| 209 | + if (_openPopups > 0) return true; |
199 | 210 | // Urlbar autocomplete dropdown is open — hiding would break UX |
200 | 211 | if (urlbar?.hasAttribute("breakout-extend")) return true; |
201 | 212 | // A toolbar button menu is open (e.g. hamburger, extensions) |
202 | 213 | if (document.querySelector("toolbarbutton[open='true']")) return true; |
203 | 214 | // 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) |
206 | 215 | if (document.querySelector(".tabbrowser-tab[multiselected]")) return true; |
207 | 216 | return false; |
208 | 217 | } |
|
516 | 525 | const isCompact = sidebarMain.hasAttribute("data-pfx-compact"); |
517 | 526 | compactItem.setAttribute( |
518 | 527 | "label", |
519 | | - isCompact ? "Turn Compact Off" : "Turn Compact On" |
| 528 | + isCompact ? "Disable Compact" : "Enable Compact" |
520 | 529 | ); |
521 | 530 | // Force-show native sidebar items Firefox hid for our button |
522 | 531 | if (customizeSidebar) customizeSidebar.hidden = false; |
|
0 commit comments