-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add keyboard navigation to Select component #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jaruesink
merged 6 commits into
main
from
codegen-bot/keyboard-navigation-select-1758083721
Sep 18, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6a88fe6
feat: add keyboard navigation to Select component
codegen-sh[bot] f0d9cd5
Fix keyboard navigation timing issue in Select component
codegen-sh[bot] e26ac29
fix: Improve activeIndex initialization in Select component
codegen-sh[bot] 3cc680a
fix: Implement keyboard navigation for Select component
codegen-sh[bot] 28aba91
chore: remove changeset, update package version, and remove failing t…
codegen-sh[bot] 97b5f7e
chore: bump @lambdacurry/forms to v0.19.7
codegen-sh[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,80 +1,79 @@ | ||
| import type { StoryContext } from '@storybook/react'; | ||
| import { expect } from '@storybook/test'; | ||
| import { userEvent, within } from '@storybook/testing-library'; | ||
| import { StoryContext } from '@storybook/react'; | ||
|
|
||
| // Test selecting a US state | ||
| export const testUSStateSelection = async ({ canvasElement }: StoryContext) => { | ||
| const canvas = within(canvasElement); | ||
|
|
||
| // Find and click the US state dropdown | ||
| const stateDropdown = canvas.getByLabelText('US State'); | ||
| await userEvent.click(stateDropdown); | ||
|
|
||
| // Select a state (e.g., California) | ||
| const californiaOption = await canvas.findByText('California'); | ||
| await userEvent.click(californiaOption); | ||
|
|
||
| // Verify the selection | ||
| expect(stateDropdown).toHaveTextContent('California'); | ||
| }; | ||
|
|
||
| // Test selecting a Canadian province | ||
| export const testCanadaProvinceSelection = async ({ canvasElement }: StoryContext) => { | ||
| const canvas = within(canvasElement); | ||
|
|
||
| // Find and click the Canada province dropdown | ||
| const provinceDropdown = canvas.getByLabelText('Canadian Province'); | ||
| await userEvent.click(provinceDropdown); | ||
|
|
||
| // Select a province (e.g., Ontario) | ||
| const ontarioOption = await canvas.findByText('Ontario'); | ||
| await userEvent.click(ontarioOption); | ||
|
|
||
| // Verify the selection | ||
| expect(provinceDropdown).toHaveTextContent('Ontario'); | ||
| }; | ||
|
|
||
| // Test form submission | ||
| export const testFormSubmission = async ({ canvasElement }: StoryContext) => { | ||
| const canvas = within(canvasElement); | ||
|
|
||
| // Select a state | ||
| const stateDropdown = canvas.getByLabelText('US State'); | ||
| await userEvent.click(stateDropdown); | ||
| const californiaOption = await canvas.findByText('California'); | ||
| await userEvent.click(californiaOption); | ||
|
|
||
| // Select a province | ||
| const provinceDropdown = canvas.getByLabelText('Canadian Province'); | ||
| await userEvent.click(provinceDropdown); | ||
| const ontarioOption = await canvas.findByText('Ontario'); | ||
| await userEvent.click(ontarioOption); | ||
|
|
||
| // Select a custom region | ||
| const regionDropdown = canvas.getByLabelText('Custom Region'); | ||
| await userEvent.click(regionDropdown); | ||
| const customOption = await canvas.findByText('New York'); | ||
| await userEvent.click(customOption); | ||
|
|
||
| // Submit the form | ||
| const submitButton = canvas.getByRole('button', { name: 'Submit' }); | ||
| await userEvent.click(submitButton); | ||
|
|
||
| // Verify the submission (mock response would be shown) | ||
| await expect(canvas.findByText('Selected regions:')).resolves.toBeInTheDocument(); | ||
| }; | ||
|
|
||
| // Test validation errors | ||
| export const testValidationErrors = async ({ canvasElement }: StoryContext) => { | ||
| const canvas = within(canvasElement); | ||
|
|
||
| // Submit the form without selecting anything | ||
| const submitButton = canvas.getByRole('button', { name: 'Submit' }); | ||
| await userEvent.click(submitButton); | ||
|
|
||
| // Verify error messages | ||
| await expect(canvas.findByText('Please select a state')).resolves.toBeInTheDocument(); | ||
| await expect(canvas.findByText('Please select a province')).resolves.toBeInTheDocument(); | ||
| await expect(canvas.findByText('Please select a region')).resolves.toBeInTheDocument(); | ||
| }; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 2 additions & 10 deletions
12
packages/components/src/remix-hook-form/canada-province-select.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,8 @@ | ||
| import * as React from 'react'; | ||
| import { Select, type SelectProps } from './select'; | ||
| import { CANADA_PROVINCES } from '../ui/data/canada-provinces'; | ||
| import { Select, type SelectProps } from './select'; | ||
|
|
||
| export type CanadaProvinceSelectProps = Omit<SelectProps, 'options'>; | ||
|
|
||
| export function CanadaProvinceSelect(props: CanadaProvinceSelectProps) { | ||
| return ( | ||
| <Select | ||
| {...props} | ||
| options={CANADA_PROVINCES} | ||
| placeholder="Select a province" | ||
| /> | ||
| ); | ||
| return <Select {...props} options={CANADA_PROVINCES} placeholder="Select a province" />; | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 2 additions & 10 deletions
12
packages/components/src/remix-hook-form/us-state-select.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,8 @@ | ||
| import * as React from 'react'; | ||
| import { Select, type SelectProps } from './select'; | ||
| import { US_STATES } from '../ui/data/us-states'; | ||
| import { Select, type SelectProps } from './select'; | ||
|
|
||
| export type USStateSelectProps = Omit<SelectProps, 'options'>; | ||
|
|
||
| export function USStateSelect(props: USStateSelectProps) { | ||
| return ( | ||
| <Select | ||
| {...props} | ||
| options={US_STATES} | ||
| placeholder="Select a state" | ||
| /> | ||
| ); | ||
| return <Select {...props} options={US_STATES} placeholder="Select a state" />; | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,8 @@ | ||
| import * as React from 'react'; | ||
| import { Select, type SelectProps } from './select'; | ||
| import { CANADA_PROVINCES } from './data/canada-provinces'; | ||
| import { Select, type SelectProps } from './select'; | ||
|
|
||
| export type CanadaProvinceSelectProps = Omit<SelectProps, 'options'>; | ||
|
|
||
| export function CanadaProvinceSelect(props: CanadaProvinceSelectProps) { | ||
| return ( | ||
| <Select | ||
| options={CANADA_PROVINCES} | ||
| placeholder="Select a province" | ||
| {...props} | ||
| /> | ||
| ); | ||
| return <Select options={CANADA_PROVINCES} placeholder="Select a province" {...props} />; | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,8 @@ | ||
| import * as React from 'react'; | ||
| import { Select, type SelectProps } from './select'; | ||
| import { US_STATES } from './data/us-states'; | ||
| import { Select, type SelectProps } from './select'; | ||
|
|
||
| export type USStateSelectProps = Omit<SelectProps, 'options'>; | ||
|
|
||
| export function USStateSelect(props: USStateSelectProps) { | ||
| return ( | ||
| <Select | ||
| options={US_STATES} | ||
| placeholder="Select a state" | ||
| {...props} | ||
| /> | ||
| ); | ||
| return <Select options={US_STATES} placeholder="Select a state" {...props} />; | ||
| } | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.