make fields open with space (to avoid conflicts)

This commit is contained in:
andrzej 2024-07-02 17:18:23 +02:00
parent 380fc56d17
commit 0138e1aa2a
2 changed files with 3 additions and 10 deletions

Binary file not shown.

View File

@ -27,9 +27,7 @@ export default function NumberInputCell(props: CellContext<any, any>) {
defaultValues: {
[column]: props.cell.getValue()
},
// mode: "onChange"
})
const isDirty = form.formState.isDirty
function onSubmit(value: z.infer<typeof formSchema>) {
toast({
@ -67,20 +65,15 @@ export default function NumberInputCell(props: CellContext<any, any>) {
className="w-full h-fit flex items-center justify-center"
tabIndex={0}
onKeyDown={e => {
if (e.code === "Enter" && !isActive) {
if (e.code === "Space" && !isActive) {
setIsActive(true)
}
}}
>
{isActive ?
<Form {...form}>
<form onSubmit={e => {
e.preventDefault()
if (isDirty) {
console.log("SUBMIT")
form.handleSubmit(onSubmit, onErrors)
}
}} >
<form onSubmit={form.handleSubmit(onSubmit, onErrors)}
>
<FormField
control={form.control}
name={column}