Skip to content

Commit 5f13995

Browse files
committed
fix unintuitive number input behaviour (rel to #783)
1 parent a82a3cd commit 5f13995

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

next/components/IndividualColumnFilter.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ function GSettingsNumberFilter<Instance>({
3939
placeholder={`Filter ${column.columnDef.header as string}...`}
4040
className="w-full px-2 py-1 text-sm border border-gray-5 bg-white font-normal rounded"
4141
min={0}
42+
onKeyDown={(e) => {
43+
// number inputs can be unintuitive when deleting the last digit. This helps with that.
44+
if (e.key === "Backspace" && value < 10) {
45+
e.preventDefault();
46+
e.stopPropagation();
47+
(e.target as HTMLInputElement).select();
48+
}
49+
}}
4250
/>
4351
);
4452
}

0 commit comments

Comments
 (0)