Skip to content

Commit 82647b6

Browse files
committed
Enhancement: submit at Enter key press in text filter card
1 parent b5b1d29 commit 82647b6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

smoosense-gui/src/lib/features/filters/TextFilterCard.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,21 @@ export default function TextFilterCard({ columnName, onClose }: TextFilterCardPr
7373
}
7474
}, [reduxFilter])
7575

76-
const applyTextFilterChanges = () => {
76+
const applyTextFilterChanges = useCallback(() => {
7777
if (!debouncedSearchTerm || !debouncedSearchTerm.trim()) {
7878
applyTextFilter(undefined)
7979
} else {
8080
const filter = createTextColumnFilter(debouncedSearchTerm.trim(), nullFilter)
8181
applyTextFilter(filter)
8282
}
83-
}
83+
}, [debouncedSearchTerm, nullFilter, applyTextFilter])
84+
85+
const handleKeyDown = useCallback((e: React.KeyboardEvent<HTMLInputElement>) => {
86+
if (e.key === 'Enter') {
87+
e.preventDefault()
88+
applyTextFilterChanges()
89+
}
90+
}, [applyTextFilterChanges])
8491

8592
return (
8693
<div className="min-w-[400px]">
@@ -103,6 +110,7 @@ export default function TextFilterCard({ columnName, onClose }: TextFilterCardPr
103110
type="text"
104111
value={searchTerm}
105112
onChange={handleSearchTermChange}
113+
onKeyDown={handleKeyDown}
106114
placeholder="Enter search term..."
107115
className="w-full pl-10 pr-4 py-2 text-sm border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
108116
/>

0 commit comments

Comments
 (0)