Merge pull request #1004 from lowdefy/selector-search-bounce

fix(blocks-antd): Added debounce condition to Selector and MultipleSelector.
This commit is contained in:
Sam 2021-11-29 10:57:21 +02:00 committed by GitHub
commit 8f44e1a2ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -110,8 +110,10 @@ const MultipleSelector = ({
}}
onSearch={async (value) => {
setFetch(true);
await methods.triggerEvent({ name: 'onSearch', event: { value } });
setFetch(false);
const result = await methods.triggerEvent({ name: 'onSearch', event: { value } });
if (!result.bounced) {
setFetch(false);
}
}}
>
{uniqueValueOptions.map((opt, i) =>

View File

@ -98,8 +98,10 @@ const Selector = ({
}}
onSearch={async (value) => {
setFetch(true);
await methods.triggerEvent({ name: 'onSearch', event: { value } });
setFetch(false);
const result = await methods.triggerEvent({ name: 'onSearch', event: { value } });
if (!result.bounced) {
setFetch(false);
}
}}
value={getValueIndex(value, uniqueValueOptions)}
>