Combobox: Call loadOptions with current input value when reopening menu (#95573)

This commit is contained in:
Josh Hunt 2024-10-30 14:27:13 +00:00 committed by GitHub
parent 048ba14c34
commit fe4f44723d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -195,7 +195,7 @@ export const Combobox = <T extends string | number>({
setItems(customValueOption ? [customValueOption, ...filteredItems] : filteredItems);
},
onIsOpenChange: ({ isOpen }) => {
onIsOpenChange: ({ isOpen, inputValue }) => {
// Default to displaying all values when opening
if (isOpen && !isAsync) {
setItems(options);
@ -204,7 +204,7 @@ export const Combobox = <T extends string | number>({
if (isOpen && isAsync) {
setAsyncLoading(true);
loadOptions('').then((options) => {
loadOptions(inputValue ?? '').then((options) => {
setItems(options);
setAsyncLoading(false);
});