Fix JS error when clicking an item in a filter list

demo
Zef Hemel 2022-11-19 15:22:33 +01:00
parent f28b0a33bc
commit be6d98ba1a
1 changed files with 3 additions and 4 deletions

View File

@ -129,14 +129,12 @@ export function FilterList({
value={text} value={text}
placeholder={placeholder} placeholder={placeholder}
ref={searchBoxRef} ref={searchBoxRef}
// onChange={filterUpdate}
onBlur={(e) => { onBlur={(e) => {
if (!exiting) { if (!exiting && searchBoxRef.current) {
searchBoxRef.current!.focus(); searchBoxRef.current.focus();
} }
}} }}
onKeyUp={(e) => { onKeyUp={(e) => {
// console.log("Key up", / e);
if (onKeyPress) { if (onKeyPress) {
onKeyPress(e.key, text); onKeyPress(e.key, text);
} }
@ -207,6 +205,7 @@ export function FilterList({
}} }}
onClick={(e) => { onClick={(e) => {
e.preventDefault(); e.preventDefault();
exiting = true;
onSelect(option); onSelect(option);
}} }}
> >