|
196 | 196 | // [breakout-extend] — we use querySelector which is simpler and |
197 | 197 | // sufficient for our single-element case. |
198 | 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. |
| 199 | + // hide the sidebar while a menu is visible. Only count XUL popups, |
| 200 | + // not HTML popovers like the urlbar's breakout. |
201 | 201 | 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 | + } |
205 | 211 | }); |
206 | 212 |
|
207 | 213 | function isGuarded() { |
208 | | - // A popup/context menu is open |
209 | 214 | if (_openPopups > 0) return true; |
210 | | - // Urlbar autocomplete dropdown is open — hiding would break UX |
211 | 215 | if (urlbar?.hasAttribute("breakout-extend")) return true; |
212 | | - // A toolbar button menu is open (e.g. hamburger, extensions) |
213 | 216 | if (document.querySelector("toolbarbutton[open='true']")) return true; |
214 | | - // Tabs are being multi-selected or dragged |
215 | 217 | if (document.querySelector(".tabbrowser-tab[multiselected]")) return true; |
216 | 218 | return false; |
217 | 219 | } |
|
323 | 325 | urlbar.showPopover(); |
324 | 326 | } else { |
325 | 327 | 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 | + } |
326 | 334 | } |
327 | 335 | }).observe(urlbar, { attributes: true, attributeFilter: ["breakout-extend"] }); |
328 | 336 | } |
|
0 commit comments