Skip to content

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

Merged
trunk-io[bot] merged 4 commits into
PostHog:mainfrom
aleexzxzxzx:posthog-code/fix-sidebar-peek-projectswitcher
Jul 17, 2026
Merged

fix(sidebar): keep the peeked sidebar open while the ProjectSwitcher menu is open#3484
trunk-io[bot] merged 4 commits into
PostHog:mainfrom
aleexzxzxzx:posthog-code/fix-sidebar-peek-projectswitcher

Conversation

@aleexzxzxzx

Copy link
Copy Markdown
Contributor

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).

@trunk-io

trunk-io Bot commented Jul 15, 2026

Copy link
Copy Markdown

😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details.

@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
auto-merge was automatically disabled July 16, 2026 13:43

Head branch was pushed to by a user without write access

@aleexzxzxzx
aleexzxzxzx force-pushed the posthog-code/fix-sidebar-peek-projectswitcher branch from 48dd8e9 to 485b826 Compare July 16, 2026 13:43
… 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.

Generated-By: PostHog Code
Task-Id: 61d7100a-78b9-41ca-9226-9b1bee296f1d
@aleexzxzxzx
aleexzxzxzx force-pushed the posthog-code/fix-sidebar-peek-projectswitcher branch from 485b826 to e3783de Compare July 16, 2026 13:46
@aleexzxzxzx

Copy link
Copy Markdown
Contributor Author

@tatoalo Done! Signed the commit, it shows as Verified now. No worries, thanks for the heads up 🙏

@tatoalo
tatoalo enabled auto-merge (squash) July 16, 2026 13:55
@aleexzxzxzx

aleexzxzxzx commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

What's making the Trunk Impacted Targets / upload check fail? Anything I should do on my end? @tatoalo

@tatoalo

tatoalo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@aleexzxzxzx we are using trunk for merge queueing but it seems it's having some issues (their infra), will keep an eye on this and merge asap 🙏🏻

@tatoalo

tatoalo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

/trunk merge

@trunk-io
trunk-io Bot merged commit bca6aa1 into PostHog:main Jul 17, 2026
29 checks passed
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