Skip to content
This repository was archived by the owner on May 26, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/web/content/docs/components/multi-select.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ import {
<MultiSelectItem value="vue">Vue</MultiSelectItem>
<MultiSelectItem value="angular">Angular</MultiSelectItem>
<MultiSelectItem value="svelte">Svelte</MultiSelectItem>
</MultiSelectList>>
</MultiSelectList>
</MultiSelectContent>
</MultiSel>
</MultiSelect>
```

## Examples
Expand Down
13 changes: 10 additions & 3 deletions apps/web/registry/default/ui/multi-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const MultiSelect: React.FC<MultiSelectProps> = ({
onValueChangeProp(state, items)
}
},
[onValueChangeProp],
[onValueChangeProp, itemCache],
)

const [value, setValue] = useControllableState({
Expand Down Expand Up @@ -168,6 +168,7 @@ const MultiSelect: React.FC<MultiSelectProps> = ({
maxCount,
handleSelect,
handleDeselect,
itemCache
])

return (
Expand Down Expand Up @@ -325,6 +326,8 @@ const MultiSelectValue = React.forwardRef<
},
)

MultiSelectValue.displayName = 'MultiSelectValue'

const MultiSelectSearch = React.forwardRef<
React.ElementRef<typeof CommandInput>,
React.ComponentPropsWithoutRef<typeof CommandInput>
Expand Down Expand Up @@ -410,6 +413,8 @@ const MultiSelectContent = React.forwardRef<
)
})

MultiSelectContent.displayName = 'MultiSelectContent'

type MultiSelectItemProps = React.ComponentPropsWithoutRef<typeof CommandItem> &
Partial<MultiSelectOptionItem> & {
onSelect?: (value: string, item: MultiSelectOptionItem) => void
Expand Down Expand Up @@ -456,7 +461,7 @@ const MultiSelectItem = React.forwardRef<
React.useEffect(() => {
if (value)
itemCache.set(value, item!)
}, [selected, value, item])
}, [selected, value, item, itemCache])

const disabled = Boolean(
disabledProp || (!selected && maxCount && contextValue.length >= maxCount),
Expand Down Expand Up @@ -495,6 +500,8 @@ const MultiSelectItem = React.forwardRef<
},
)

MultiSelectItem.displayName = 'MultiSelectItem'

const MultiSelectGroup = React.forwardRef<
React.ElementRef<typeof CommandGroup>,
React.ComponentPropsWithoutRef<typeof CommandGroup>
Expand Down Expand Up @@ -585,4 +592,4 @@ export {
MultiSelectSeparator,
MultiSelectEmpty,
renderMultiSelectOptions,
}
}
13 changes: 10 additions & 3 deletions apps/web/registry/miami/ui/multi-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const MultiSelect: React.FC<MultiSelectProps> = ({
onValueChangeProp(state, items)
}
},
[onValueChangeProp],
[onValueChangeProp, itemCache],
)

const [value, setValue] = useControllableState({
Expand Down Expand Up @@ -168,6 +168,7 @@ const MultiSelect: React.FC<MultiSelectProps> = ({
maxCount,
handleSelect,
handleDeselect,
itemCache
])

return (
Expand Down Expand Up @@ -325,6 +326,8 @@ const MultiSelectValue = React.forwardRef<
},
)

MultiSelectValue.displayName = 'MultiSelectValue'

const MultiSelectSearch = React.forwardRef<
React.ElementRef<typeof CommandInput>,
React.ComponentPropsWithoutRef<typeof CommandInput>
Expand Down Expand Up @@ -410,6 +413,8 @@ const MultiSelectContent = React.forwardRef<
)
})

MultiSelectContent.displayName = 'MultiSelectContent'

type MultiSelectItemProps = React.ComponentPropsWithoutRef<typeof CommandItem> &
Partial<MultiSelectOptionItem> & {
onSelect?: (value: string, item: MultiSelectOptionItem) => void
Expand Down Expand Up @@ -456,7 +461,7 @@ const MultiSelectItem = React.forwardRef<
React.useEffect(() => {
if (value)
itemCache.set(value, item!)
}, [selected, value, item])
}, [selected, value, item, itemCache])

const disabled = Boolean(
disabledProp || (!selected && maxCount && contextValue.length >= maxCount),
Expand Down Expand Up @@ -495,6 +500,8 @@ const MultiSelectItem = React.forwardRef<
},
)

MultiSelectItem.displayName = 'MultiSelectItem'

const MultiSelectGroup = React.forwardRef<
React.ElementRef<typeof CommandGroup>,
React.ComponentPropsWithoutRef<typeof CommandGroup>
Expand Down Expand Up @@ -585,4 +592,4 @@ export {
MultiSelectSeparator,
MultiSelectEmpty,
renderMultiSelectOptions,
}
}
Loading