Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/@react-types/combobox/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type MenuTriggerAction = 'focus' | 'input' | 'manual';
export type SelectionMode = 'single' | 'multiple';
export type ValueType<M extends SelectionMode> = M extends 'single' ? Key | null : readonly Key[];
export type ChangeValueType<M extends SelectionMode> = M extends 'single' ? Key | null : Key[];
type ValidationType<M extends SelectionMode> = M extends 'single' ? Key : Key[];
type ValidationType<M extends SelectionMode> = M extends 'single' ? Key | null : Key[];
Copy link
Member

Choose a reason for hiding this comment

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

this seems incorrect, null should not be allowed. it's considered valid unless marked required in which case required validation will take care of it

if the assertion that allowsCustomValue can be called with null, then that seems like a bug

Copy link
Contributor Author

@lixiaoyan lixiaoyan Mar 16, 2026

Choose a reason for hiding this comment

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

Currently, we pass { inputValue, value } as the argument to the validate function, and we only skip validation when this argument is null. This means that in single-select scenarios, arg.value can indeed be null.

For multi-select scenarios, however, we intentionally set the entire argument to null within useComboBoxState to bypass validation. This admittedly introduces an inconsistency. However, given that arg.inputValue is primarily used for filtering in multi-select, skipping validation in this context is reasonable to some extent.

On the other hand, for single-select—especially when allowsCustomValue is enabled—we might have validations that rely solely on arg.inputValue (ignoring arg.value entirely). Therefore, I believe it makes sense to let the validation execute normally even when arg.value is null.

https://stackblitz.com/edit/49ftjwz8?file=src%2FExample.tsx

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have split the changes into two separate PRs (the other one is #9795), so they can now be reviewed independently.

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense. Thanks for explaining.


export interface ComboBoxValidationValue<M extends SelectionMode = 'single'> {
/**
Expand Down
Loading