Skip to content

Keep a floating panel on the side it opened on - #387

Merged
PatrikBak merged 1 commit into
mainfrom
patrik/select-panel-side-lock
Aug 22, 2026
Merged

Keep a floating panel on the side it opened on#387
PatrikBak merged 1 commit into
mainfrom
patrik/select-panel-side-lock

Conversation

@PatrikBak

Copy link
Copy Markdown
Owner

A panel whose content resizes while it is open hands floating-ui's flip() a new answer on every keystroke. Open the country picker near the bottom of the page and it goes upward for want of room below; narrow the list by typing and it now fits below, so flip moves it there; clear the query and it stays below, overflowing.

The facet popovers have the same shape and more triggers for it: a search box, collapsible sections, an expanding tree, and a header that only a top-side popover carries, so a flip changes the very height that decided it.

useFloatingPanel now owns the offset/flip/shift/size chain for every floating panel and takes pinSide, which settles the side as the panel opens and drops flip from the chain outright. Dropping it is what makes the pin hold: floating-ui keeps the chain it was first given unless a new one differs, and it compares each rule's function by source text, so a flip left in place with different options would be ignored. A shorter chain is the difference it does notice.

That same comparison had frozen the facets' size rule at mount, so its capture of the filtered count never moved and the popover's min-height was stuck at whatever the first render saw. The hook reads the caller's rule through a ref whose wrapper never changes shape, which unfreezes it. Pinning first is what makes that safe, and the facet popover's min-height now moves as the list filters.

Select comes off Headless UI's anchor prop for the same reason: it applies an unconfigurable flip() and AnchorProps offers no way to say otherwise. Both selects now share use-select-panel, so select-parts is dressing only.

Tooltips pass pinSide: false. Their content is fixed, so nothing they do can hand flipping a new answer, and re-flipping is what keeps them on screen when the layout shifts underneath.

🤖 Generated with Claude Code

A panel whose content resizes while it is open hands floating-ui's flip() a
new answer on every keystroke. Open the country picker near the bottom of the
page and it goes upward for want of room below; narrow the list by typing and
it now fits below, so flip moves it there; clear the query and it stays below,
overflowing. The facet popovers have the same shape and more triggers for it:
a search box, collapsible sections, an expanding tree, and a header that only
a top-side popover carries, so a flip changes the height that decided it.

useFloatingPanel now owns the offset/flip/shift/size chain for every panel and
takes pinSide, which settles the side as the panel opens and drops flip from
the chain outright. Dropping it is what makes the pin hold: floating-ui keeps
the chain it was first given unless a new one differs, and it compares each
rule's function by source text, so a flip left in place with different options
would be ignored. A shorter chain is the difference it does notice.

That same comparison had frozen the facets' size rule at mount, so its capture
of the filtered count never moved and the popover's min-height was stuck at
whatever the first render saw. The hook reads the caller's rule through a ref
whose wrapper never changes shape, which unfreezes it. Pinning first is what
makes that safe.

Select comes off Headless UI's anchor prop for the same reason: it applies an
unconfigurable flip and AnchorProps has no way to say otherwise. Both selects
now share use-select-panel, so select-parts is dressing only.

Tooltips pass pinSide: false. Their content is fixed, so nothing they do can
hand flipping a new answer, and re-flipping is what keeps them on screen.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
math-comps Ready Ready Preview Aug 22, 2026 5:35pm

@PatrikBak
PatrikBak enabled auto-merge August 22, 2026 17:35
@PatrikBak
PatrikBak merged commit 1a40524 into main Aug 22, 2026
5 checks passed
@PatrikBak
PatrikBak deleted the patrik/select-panel-side-lock branch August 22, 2026 17:41
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.

1 participant