Skip to content

Commit

Permalink
pressing enter no longer freezes page
Browse files Browse the repository at this point in the history
  • Loading branch information
Israellund authored and ilijabojanovic committed Dec 2, 2024
1 parent 7aabeeb commit 0021113
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ export const CWSearchBar: FC<SearchBarProps> = ({

const resetSearchBar = () => setSearchTerm('');

const handleOnInput = (e: ChangeEvent<HTMLInputElement>) =>
const handleOnInput = (e: ChangeEvent<HTMLInputElement>) => {
e.stopPropagation();
setSearchTerm(e.target.value);
};

const handleOnKeyUp = (e) => {
e.stopPropagation();
if (e.key === 'Enter') {
e.preventDefault();
handleGoToSearchPage();

if (size === 'small') {
Expand All @@ -112,6 +116,7 @@ export const CWSearchBar: FC<SearchBarProps> = ({
};

const handleOnKeyDown = (e: any) => {
e.stopPropagation();
if (e.key === 'Backspace' && searchTerm.length === 0) {
setShowTag(false);
}
Expand Down

0 comments on commit 0021113

Please sign in to comment.