From 533bf2d450a2980c31b6682ad3fe35b26971425e Mon Sep 17 00:00:00 2001 From: Carol Sachdeva Date: Thu, 16 Jun 2022 19:05:00 +0800 Subject: [PATCH 1/3] search hotfix --- packages/p2p/src/components/search-box/search-box.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/p2p/src/components/search-box/search-box.jsx b/packages/p2p/src/components/search-box/search-box.jsx index d160ea8bd920..bd5839e49fc3 100644 --- a/packages/p2p/src/components/search-box/search-box.jsx +++ b/packages/p2p/src/components/search-box/search-box.jsx @@ -13,6 +13,14 @@ const SearchBox = ({ className, onClear, onSearch, placeholder }) => { } }; + const onSearchKeyDown = (search, submitForm) => { + if (!search) { + onClear(); + } else { + submitForm(); + } + }; + const onSearchKeyUp = submitForm => { clearTimeout(typing_timer); @@ -44,6 +52,7 @@ const SearchBox = ({ className, onClear, onSearch, placeholder }) => { type='text' name='search' placeholder={placeholder} + onKeyDown={() => onSearchKeyDown(search, submitForm)} onKeyUp={() => onSearchKeyUp(submitForm)} onFocus={submitForm} leading_icon={} From abfc7b373dc6941e15f825840de4cfcc9176cfe9 Mon Sep 17 00:00:00 2001 From: Carol Sachdeva Date: Fri, 17 Jun 2022 16:32:24 +0800 Subject: [PATCH 2/3] search hotfix --- packages/p2p/src/components/search-box/search-box.jsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/p2p/src/components/search-box/search-box.jsx b/packages/p2p/src/components/search-box/search-box.jsx index bd5839e49fc3..70fb0fbd3049 100644 --- a/packages/p2p/src/components/search-box/search-box.jsx +++ b/packages/p2p/src/components/search-box/search-box.jsx @@ -13,13 +13,7 @@ const SearchBox = ({ className, onClear, onSearch, placeholder }) => { } }; - const onSearchKeyDown = (search, submitForm) => { - if (!search) { - onClear(); - } else { - submitForm(); - } - }; + const onSearchKeyDown = (search, submitForm) => (search ? submitForm() : onClear()); const onSearchKeyUp = submitForm => { clearTimeout(typing_timer); From b7d1352ad6416bcb303201280ace7a705fa93747 Mon Sep 17 00:00:00 2001 From: Carol Sachdeva Date: Sat, 18 Jun 2022 01:12:34 +0800 Subject: [PATCH 3/3] fix: intermittent issue --- .../p2p/src/components/search-box/search-box.jsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/p2p/src/components/search-box/search-box.jsx b/packages/p2p/src/components/search-box/search-box.jsx index 70fb0fbd3049..1081641544d6 100644 --- a/packages/p2p/src/components/search-box/search-box.jsx +++ b/packages/p2p/src/components/search-box/search-box.jsx @@ -13,18 +13,19 @@ const SearchBox = ({ className, onClear, onSearch, placeholder }) => { } }; - const onSearchKeyDown = (search, submitForm) => (search ? submitForm() : onClear()); - - const onSearchKeyUp = submitForm => { + const onSearchKeyUpDown = submitForm => { clearTimeout(typing_timer); const typing_timer = setTimeout(() => { submitForm(); - }, 1000); + }, 500); }; const onSearchSubmit = ({ search }) => { if (!search.trim()) { + if (typeof onClear === 'function') { + onClear(); + } return; } @@ -46,8 +47,8 @@ const SearchBox = ({ className, onClear, onSearch, placeholder }) => { type='text' name='search' placeholder={placeholder} - onKeyDown={() => onSearchKeyDown(search, submitForm)} - onKeyUp={() => onSearchKeyUp(submitForm)} + onKeyDown={() => onSearchKeyUpDown(submitForm)} + onKeyUp={() => onSearchKeyUpDown(submitForm)} onFocus={submitForm} leading_icon={} trailing_icon={