Skip to content

feat(Select): add position prop & align-item#1954

Open
maxffarrell wants to merge 23 commits into
huntabyte:mainfrom
maxffarrell:select-align-item
Open

feat(Select): add position prop & align-item#1954
maxffarrell wants to merge 23 commits into
huntabyte:mainfrom
maxffarrell:select-align-item

Conversation

@maxffarrell

@maxffarrell maxffarrell commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@changeset-bot

changeset-bot Bot commented Feb 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e80a153

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
bits-ui Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Feb 17, 2026

Copy link
Copy Markdown
Contributor
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
bits-ui ✅ Ready (View Log) Visit Preview e80a153

Comment thread docs/content/components/select.md Outdated
Comment thread packages/bits-ui/src/lib/bits/select/select.svelte.ts Outdated
@huntabyte

Copy link
Copy Markdown
Owner
CleanShot.2026-02-19.at.14.55.28.mp4

This is close, but it needs to account for the scroll buttons potentially being there. I would expect clicking on the trigger and then again quickly without moving my mouse it would hit the selected item and not the scroll button.

I will give this a more thorough review when I have some time, as I see some things in the constructor etc that look like they are causing extra work even when the position is not item-aligned.

Thank you!

@pkg-pr-new

pkg-pr-new Bot commented May 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/bits-ui@1954

commit: e80a153

maxffarrell and others added 2 commits May 3, 2026 22:19
Adds documentation, API reference, and demo scaffolding for the upcoming
`position="item-aligned"` feature. Implementation removed — will be
re-ported from Radix UI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Ports the exact SelectItemAlignedPosition algorithm from Radix UI's
select.tsx. Uses a two-div structure (fixed wrapper + content) with
direct DOM style writes, matching Radix's approach:

- Aligns the selected item's center vertically with the trigger's center
- Aligns the item's left edge with the trigger value node's left edge
- Expands the content wrapper as the user scrolls (shouldExpandOnScroll)
- Repositions once when scroll buttons appear (handleScrollButtonChange)
- Closes the select on window resize (Radix behaviour)

Also adds `getAllItemNodes()` to SelectBaseRootState to correctly detect
first/last items (including disabled) for edge padding calculations.
Combobox content types omit `position` since item-aligned doesn't apply
when filtering by typing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…s trailing scroll-down arrow

In item-aligned mode, setHighlightedNode's scrollIntoView call was racing the
positioner and shifting the selected item ~8px from the trigger. Skip that
scroll when item-aligned is active. Additionally, when the last item is at
the trigger position the algorithm leaves a tiny strip of scrollable space
below it; suppress the scroll-down arrow when there is no next item to scroll
to so the menu visually ends at the last item's bottom edge.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@maxffarrell maxffarrell marked this pull request as ready for review May 9, 2026 22:28
…elpers

The dismissable layer attaches its document-level pointerdown listener via
setTimeout(1) to skip the bootstrapping pointerdown event. Tests that open
the menu and immediately click outside can race this delay, leaving the
listener unattached when the click fires. Add a vi.waitFor on
globalThis.bitsDismissableLayers in the open helpers so subsequent outside
clicks reliably hit the dismiss handler.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@maxffarrell maxffarrell marked this pull request as draft May 9, 2026 23:12
@maxffarrell maxffarrell marked this pull request as ready for review May 9, 2026 23:19
@maxffarrell

Copy link
Copy Markdown
Contributor Author

Bits doesn't lock page scroll when the portal is open the way Radix does, which raises the question of how to handle the portal size when scrolling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

publish:preview Add to PRs to publish preview packages with `pkg-pr-new`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants