diff --git a/packages/p2p/src/components/search-box/search-box.jsx b/packages/p2p/src/components/search-box/search-box.jsx index d160ea8bd920..1081641544d6 100644 --- a/packages/p2p/src/components/search-box/search-box.jsx +++ b/packages/p2p/src/components/search-box/search-box.jsx @@ -13,16 +13,19 @@ const SearchBox = ({ className, onClear, onSearch, placeholder }) => { } }; - 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; } @@ -44,7 +47,8 @@ const SearchBox = ({ className, onClear, onSearch, placeholder }) => { type='text' name='search' placeholder={placeholder} - onKeyUp={() => onSearchKeyUp(submitForm)} + onKeyDown={() => onSearchKeyUpDown(submitForm)} + onKeyUp={() => onSearchKeyUpDown(submitForm)} onFocus={submitForm} leading_icon={} trailing_icon={