Skip to content

Commit

Permalink
[components] Fix Select component logic to support items use case
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Oct 14, 2024
1 parent a74ec0c commit 2b9cad9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3,059 deletions.
2 changes: 1 addition & 1 deletion apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@tanstack/react-query": "^5.37.1",
"next": "14.2.2",
"react": "^18",
"react-aria-components": "^1.1.1",
"react-aria-components": "^1.4.0",
"react-dom": "^18"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion apps/vite-ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"axios": "^1.6.5",
"get-port": "^7.0.0",
"react": "^18.2.0",
"react-aria-components": "^1.1.1",
"react-aria-components": "^1.4.0",
"react-dom": "^18.2.0",
"sirv": "^2.0.4"
},
Expand Down
2 changes: 1 addition & 1 deletion apps/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@tanstack/react-router": "^1.29.2",
"axios": "^1.6.5",
"react": "^18.2.0",
"react-aria-components": "^1.2.1",
"react-aria-components": "^1.4.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
Expand Down
16 changes: 0 additions & 16 deletions packages/components/src/components/Select/Select.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ export const Default: Story = {
* Select renders options via render props `(item)=> React.ReactNode`
*/
export const Items: Story = {
render: (args) => (
// @ts-ignore I assume this is a storybook bug when passing args
<Select {...args}>
{(item: SelectItemObject) => (
<SelectItem id={item.label}>{item.value}</SelectItem>
)}
</Select>
),
args: {
name: 'field-empty',
label: 'field 1 title',
Expand All @@ -81,14 +73,6 @@ export const Items: Story = {
};

export const LotsOfItems: Story = {
render: (args) => (
// @ts-ignore I assume this is a storybook bug when passing args
<Select {...args}>
{(item: SelectItemObject) => (
<SelectItem id={item.label}>{item.value}</SelectItem>
)}
</Select>
),
args: {
name: 'field-empty',
label: 'field 1 title',
Expand Down
10 changes: 9 additions & 1 deletion packages/components/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ export function Select<T extends object>({
{description && <Text slot="description">{description}</Text>}
<FieldError>{errorMessage}</FieldError>
<Popover {...popoverProps}>
<ListBox items={items}>{children}</ListBox>
{children ? (
<ListBox items={items}>{children}</ListBox>
) : (
<ListBox items={items}>
{(item: SelectItemObject) => (
<SelectItem id={item.label}>{item.value}</SelectItem>
)}
</ListBox>
)}
</Popover>
</>
)}
Expand Down
Loading

0 comments on commit 2b9cad9

Please sign in to comment.