Skip to content

Select: auto-scroll selected option into view on open (align activeIndex to selected) - #146

Closed
codegen-sh[bot] wants to merge 1 commit into
codegen-bot/lambda-agentos-v0-1-setupfrom
codegen/lc-323-researcher-test
Closed

Select: auto-scroll selected option into view on open (align activeIndex to selected)#146
codegen-sh[bot] wants to merge 1 commit into
codegen-bot/lambda-agentos-v0-1-setupfrom
codegen/lc-323-researcher-test

Conversation

@codegen-sh

@codegen-sh codegen-sh Bot commented Sep 21, 2025

Copy link
Copy Markdown
Contributor

Requested by: Jake Ruesink

Summary

  • Implement auto-scroll of the selected option when opening the Select dropdown.
  • Center the selected/active item in view for better UX.
  • Prevent the subsequent activeIndex scroll from overriding the selected position by aligning activeIndex to the selected option on open.

Technical Changes

  • packages/components/src/ui/select.tsx
    • On open, set activeIndex to the index of the currently selected value (fallback to 0 when none).
    • Scroll both selected and active items into view with block: 'center'.
    • Keep current behavior when no selection exists (list starts at top).

Why

  • Fixes the UX issue shown in Storybook where opening a Select with a pre-selected value would display the top of the list instead of the selected option.

Notes

  • No changes required in the Remix Hook Form wrapper; functionality is handled in the base UI Select.
  • If desired, we can add props later to configure alignment (center/nearest) or behavior (smooth/auto).

💻 View my work • 👤 Initiated by Jake RuesinkAbout Codegen
⛔ Remove Codegen from PR🚫 Ban action checks

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions

Copy link
Copy Markdown
Contributor

📝 Storybook Preview: View Storybook

This preview will be updated automatically when you push new changes to this PR.

Note: The preview will be available after the workflow completes and the PR is approved for deployment.

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