Skip to content

Commit

Permalink
adjusted filter (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
carellamartina authored Feb 13, 2024
1 parent d8b572c commit 1e8dd1c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/table/filters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ function DefaultColumnFilter({ column: { filterValue, setFilter, id } }) {
"input-dark"
)}
value={inputValue}
onChange={(e) => setInputValue(e.target.value)}
onChange={(e) => {
setInputValue(e.target.value);
// if the user clears the filter
if(e.target.value.length === 0) {
// Set undefined to remove the filter entirely
setFilter(undefined);
}
}}
onKeyDown={(e) => {
// the request is sent if the user presses 'enter'
if (e.key === "Enter") {
Expand All @@ -33,7 +40,7 @@ function DefaultColumnFilter({ column: { filterValue, setFilter, id } }) {
onKeyUp={(e) => {
// if the user presses 'backspace'
// the request is sent if input value is empty
if (e.key === "Backspace" && e.target.value === "") {
if (e.key === "Backspace" && e.target.value.length === 0) {
// Set undefined to remove the filter entirely
setFilter(undefined);
}
Expand Down

0 comments on commit 1e8dd1c

Please sign in to comment.