Skip to content

fix(sidebar): keep the peeked sidebar open while the ProjectSwitcher menu is open#3484

Open
aleexzxzxzx wants to merge 1 commit into
PostHog:mainfrom
aleexzxzxzx:posthog-code/fix-sidebar-peek-projectswitcher
Open

fix(sidebar): keep the peeked sidebar open while the ProjectSwitcher menu is open#3484
aleexzxzxzx wants to merge 1 commit into
PostHog:mainfrom
aleexzxzxzx:posthog-code/fix-sidebar-peek-projectswitcher

Conversation

@aleexzxzxzx

Copy link
Copy Markdown

Problem

Closes #3483

The collapsed-sidebar hover-peek (#3367) closes the peek on any directional exit,
including while the ProjectSwitcher menu is open. That menu renders in a portal
anchored to its trigger inside the sidebar, so when the peek collapses the menu is
left floating over the content, chasing its vanished anchor. Its submenus
(Project, Organization) fly out to the right, past PEEK_CLOSE_MARGIN, so
hovering them triggers the same close.

Changes

Add a "hold" to sidebarPeekStore: while a sidebar-spawned menu is open,
endSidebarPeek is a no-op, so a pointer that leaves the panel can't collapse the
peek and strand the open menu's anchor.

  • holdSidebarPeek() / releaseSidebarPeek() guard a module-level held flag;
    endSidebarPeek early-returns while held, and cancelSidebarPeek clears it.
  • ProjectSwitcher holds on open and releases on close (and on unmount) via
    onOpenChange.
  • Hover behavior is unchanged when no menu is open; once the menu closes, the peek
    collapses on the next directional exit as before.

Before / after

video.mp4

How did you test this?

  • New unit test sidebarPeekStore.test.ts (4 cases: hold blocks endSidebarPeek,
    release restores it, hold cancels a pending hide, cancelSidebarPeek clears the
    hold). pnpm --filter @posthog/ui test passes.
  • pnpm --filter @posthog/ui typecheck and Biome pass.
  • Manually in the dev app: peek the collapsed sidebar, open the ProjectSwitcher, move
    the cursor into the content and onto the submenus (stays open); close the menu, then
    move the cursor out (collapses normally).

… is open

With hover-peek active, opening the ProjectSwitcher dropdown and then moving the
pointer off the panel collapsed the sidebar while the menu (rendered in a portal
anchored to its trigger) stayed open, leaving it floating and chasing its
vanished anchor.

Add a "hold" to sidebarPeekStore: while a sidebar-spawned menu is open,
endSidebarPeek is a no-op, so the peek stays until the menu closes. The
ProjectSwitcher holds the peek on open and releases it on close (and on unmount).
Hover behaviour is unchanged when no menu is open. Adds a unit test for the hold.
@trunk-io

trunk-io Bot commented Jul 15, 2026

Copy link
Copy Markdown

✨ Submitted to Merge by @tatoalo. It will be added to the merge queue once all branch protection rules pass, there are no merge conflicts with the target branch, and impacted targets for the current PR head commit have been uploaded. See more details here.

@tatoalo

tatoalo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Thanks!

@aleexzxzxzx could you sign your commits? we are enforcing signed commits, sorry we should make that clearer 🫠

@tatoalo tatoalo enabled auto-merge (squash) July 16, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sidebar peek: the ProjectSwitcher menu detaches and floats when the peeked sidebar closes

2 participants