Skip to content

gh-11732: Resync compact mode state when the sidebar observer reconnects - #17029

Merged
mr-cheffy merged 2 commits into
zen-browser:devfrom
emagrina:fix/compact-mode-stale-active
Dec 5, 2026
Merged

mr-cheffy merged 2 commits into
zen-browser:devfrom
emagrina:fix/compact-mode-stale-active

Conversation

@emagrina

@emagrina emagrina commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

In compact mode the sidebar can stay visible and stop auto-hiding until Zen is restarted (#11732, possibly #16896).

Cause: #navigator-toolbox keeps a stale zen-compact-mode-active. The attribute is maintained by the ZenHasPolyfill observer, but ZenCompactMode disconnects that observer while compact mode is off. If a panel anchored in the sidebar closes in that window (or compact mode is turned off with it open), the attribute is never removed. Turning compact mode back on reconnects the observer, but connectObserver doesn't evaluate the current state, so the stale attribute stays until some unrelated [open]/[panelopen] mutation happens in the sidebar. That's also why toggling compact mode off and on doesn't help.

Fix: connectObserver now runs the observer's updateState right after observe(), so the attribute matches the DOM as soon as the observer is reconnected.

Tested on 1.24.3b (macOS) with the change applied to omni.ja:

  • Before: the toolbox had zen-compact-mode-active="true" with no open panel, and the sidebar stayed visible after Cmd+S. Removing the attribute by hand hid it.
  • After: toggling compact mode with Cmd+S hides the sidebar as expected, including after opening and closing sidebar menus.

zen-compact-mode-active could stay set on the sidebar after a panel
closed while compact mode was off, keeping the sidebar visible after
re-enabling compact mode.
@emagrina
emagrina requested a review from mr-cheffy as a code owner December 5, 2026 00:04
? observer.attributeFilter
: undefined,
});
// The state attribute may be stale: it can be set while the observer

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the comment

@mr-cheffy mr-cheffy self-assigned this Dec 5, 2026
@mr-cheffy

Copy link
Copy Markdown
Member

/approve
/lgtm
/good-to-test

@github-actions github-actions Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 5, 2026

@mr-cheffy mr-cheffy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@mr-cheffy
mr-cheffy merged commit 8b89278 into zen-browser:dev Dec 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm "Looks good to me", indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Compact Mode sidebar fails to auto-collapse when cursor moves away Sidebar not hiding when in compact mode

2 participants