mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 11:56:29 +00:00
fix: through collection support search (#3800)
This commit is contained in:
parent
cef18eb979
commit
4f0907be1b
@ -325,6 +325,17 @@ export const ThroughCollection = observer(
|
|||||||
setInitialValue(option?.label || value);
|
setInitialValue(option?.label || value);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
const handleSearch = (value: string) => {
|
||||||
|
if (value) {
|
||||||
|
const filteredOptions = options.filter((option) => {
|
||||||
|
return option.label.toLowerCase().includes(value.toLowerCase());
|
||||||
|
});
|
||||||
|
setOptions(filteredOptions);
|
||||||
|
} else {
|
||||||
|
const data = loadCollections();
|
||||||
|
setOptions(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
@ -333,9 +344,10 @@ export const ThroughCollection = observer(
|
|||||||
popupMatchSelectWidth={false}
|
popupMatchSelectWidth={false}
|
||||||
value={initialValue}
|
value={initialValue}
|
||||||
options={options}
|
options={options}
|
||||||
|
onSearch={handleSearch}
|
||||||
onChange={(value, option) => {
|
onChange={(value, option) => {
|
||||||
props?.onChange?.(value);
|
props?.onChange?.(value);
|
||||||
setInitialValue(option.label);
|
setInitialValue(option.label || value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user