Skip to content

Commit 826af6a

Browse files
authored
feat: auto clear navigation search input on Escape press (#17602)
* feat: auto clear navigation search input on Escape press * use onKeyDown
1 parent 05fa288 commit 826af6a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/script/page/LeftSidebar/panels/Conversations/ConversationHeader/ConversationHeader.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*/
1919

20-
import {useEffect, useRef} from 'react';
20+
import {KeyboardEvent, useEffect, useRef} from 'react';
2121

2222
import {amplify} from 'amplify';
2323

@@ -84,6 +84,12 @@ export const ConversationHeader = ({
8484
});
8585
}, []);
8686

87+
function onKeyDown(event: KeyboardEvent<HTMLInputElement>) {
88+
if (event.key === 'Escape') {
89+
setSearchValue('');
90+
}
91+
}
92+
8793
return (
8894
<>
8995
<div css={header}>
@@ -107,6 +113,7 @@ export const ConversationHeader = ({
107113

108114
{showSearchInput && (
109115
<Input
116+
onKeyDown={onKeyDown}
110117
ref={inputRef}
111118
className="label-1"
112119
value={searchValue}

0 commit comments

Comments
 (0)