Skip to content

Commit

Permalink
carol/ Search box hotfix (deriv-com#5749)
Browse files Browse the repository at this point in the history
* search hotfix

* search hotfix

* fix: intermittent issue
  • Loading branch information
carolsachdeva authored and vinu-deriv committed Jun 21, 2022
1 parent 20c3702 commit d2ee842
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/p2p/src/components/search-box/search-box.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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={<Icon className='search-box__field-icon' icon='IcSearch' />}
trailing_icon={
Expand Down

0 comments on commit d2ee842

Please sign in to comment.