[WEB-5104] chore: combobox improvements (#7933)
* chore: base ui package upgrade * feat: migrate combobox to use base-ui primitives * chore: code refactor * chore: code refactor
This commit is contained in:
parent
75cd2017a0
commit
b7c14ac9f5
1 changed files with 11 additions and 4 deletions
|
|
@ -105,7 +105,7 @@ function ComboboxOptions({
|
|||
className,
|
||||
inputClassName,
|
||||
optionsContainerClassName,
|
||||
emptyMessage,
|
||||
emptyMessage = "No results found",
|
||||
positionerClassName,
|
||||
searchQuery: controlledSearchQuery,
|
||||
onSearchQueryChange,
|
||||
|
|
@ -133,6 +133,9 @@ function ComboboxOptions({
|
|||
return React.Children.toArray(children).filter((child) => {
|
||||
if (!React.isValidElement(child)) return true;
|
||||
|
||||
// Only filter ComboboxOption components, leave other elements (like additional content) unfiltered
|
||||
if (child.type !== ComboboxOption) return true;
|
||||
|
||||
// Extract text content from child to search against
|
||||
const getTextContent = (node: React.ReactNode): string => {
|
||||
if (typeof node === "string") return node;
|
||||
|
|
@ -180,9 +183,13 @@ function ComboboxOptions({
|
|||
className={cn("overflow-auto outline-none", MAX_HEIGHT_CLASSES[maxHeight], optionsContainerClassName)}
|
||||
>
|
||||
{filteredChildren}
|
||||
{showSearch && React.Children.count(filteredChildren) === 0 && (
|
||||
<div className="px-2 py-1.5 text-sm text-custom-text-400">{emptyMessage || "No results found"}</div>
|
||||
)}
|
||||
{showSearch &&
|
||||
emptyMessage &&
|
||||
React.Children.count(
|
||||
React.Children.toArray(filteredChildren).filter(
|
||||
(child) => React.isValidElement(child) && child.type === ComboboxOption
|
||||
)
|
||||
) === 0 && <div className="px-2 py-1.5 text-sm text-custom-text-400">{emptyMessage}</div>}
|
||||
</BaseCombobox.List>
|
||||
</div>
|
||||
</BaseCombobox.Popup>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue