Skip to content

feat(combobox): implement component #807

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

Open
wants to merge 1 commit into
base: ods-react
Choose a base branch
from

Conversation

var-poro
Copy link
Contributor

No description provided.

@var-poro var-poro requested a review from a team as a code owner June 12, 2025 14:58
@var-poro var-poro force-pushed the ods-react-combobox branch from 271a191 to 44c6a33 Compare June 12, 2025 15:36
Copy link
Contributor

@dpellier dpellier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • find and replace all import type { ... } with import { type }

@@ -0,0 +1,96 @@
import type { ComboboxProp } from '../../context/useCombobox';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge with non type

export type ComboboxProp = Omit<ComponentPropsWithRef<'div'>, 'onSelect'> & {
allowCustomValue?: boolean,
children?: ReactNode,
className?: string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children and className already come from ComponentPropsWithRef

children?: ReactNode,
className?: string,
customOptionRenderer?: (item: ComboboxItemOrGroup) => JSX.Element,
defaultValue?: string[] | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove | undefined, the ? already does the same


interface ComboboxContextType {
allowCustomValue: boolean;
customOptionRenderer?: (item: ComboboxItemOrGroup) => ReactNode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=> JSX.Element to be inline with the customOptionRenderer return type of ComboboxProp

value?: string[]
}

interface ComboboxContextType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type ComboboxContextType = ComboboxProp & { ... custom prop }?
This will also avoid this diff between those two regarding ?

{ label: 'Goldfish', value: 'goldfish' },
]}
value={value}
onValueChange={details => setValue(details.value ?? [])}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can detail.value actually be undefined?

noResultLabel = 'No results found',
onValueChange,
readOnly = false,
value = [],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave empty as other components

newElementLabel = 'Add ',
noResultLabel = 'No results found',
onValueChange,
readOnly = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave empty as other components

className,
customOptionRenderer,
defaultValue,
disabled = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave empty as other components

...props
}, ref): JSX.Element => {
const [inputValue, setInputValue] = useState('');
const [internalValue, setInternalValue] = useState<string[]>(defaultValue || []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really mandatory to store the value? it should be available in the ark context already (see https://zagjs.com/components/react/combobox#machine-context)

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.

2 participants