Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

carol/ Search box hotfix #5749

Merged
merged 11 commits into from
Jun 20, 2022
9 changes: 9 additions & 0 deletions packages/p2p/src/components/search-box/search-box.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ const SearchBox = ({ className, onClear, onSearch, placeholder }) => {
}
};

const onSearchKeyDown = (search, submitForm) => {
if (!search) {
onClear();
} else {
submitForm();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using ternary operators to simplify/shorter the code.

};

const onSearchKeyUp = submitForm => {
clearTimeout(typing_timer);

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