make fields open with space (to avoid conflicts)

This commit is contained in:
andrzej 2024-07-02 17:18:23 +02:00
parent f3dbd2cb9e
commit 2e1409cf46
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: { defaultValues: {
[column]: props.cell.getValue() [column]: props.cell.getValue()
}, },
// mode: "onChange"
}) })
const isDirty = form.formState.isDirty
function onSubmit(value: z.infer<typeof formSchema>) { function onSubmit(value: z.infer<typeof formSchema>) {
toast({ toast({
@ -67,20 +65,15 @@ export default function NumberInputCell(props: CellContext<any, any>) {
className="w-full h-fit flex items-center justify-center" className="w-full h-fit flex items-center justify-center"
tabIndex={0} tabIndex={0}
onKeyDown={e => { onKeyDown={e => {
if (e.code === "Enter" && !isActive) { if (e.code === "Space" && !isActive) {
setIsActive(true) setIsActive(true)
} }
}} }}
> >
{isActive ? {isActive ?
<Form {...form}> <Form {...form}>
<form onSubmit={e => { <form onSubmit={form.handleSubmit(onSubmit, onErrors)}
e.preventDefault() >
if (isDirty) {
console.log("SUBMIT")
form.handleSubmit(onSubmit, onErrors)
}
}} >
<FormField <FormField
control={form.control} control={form.control}
name={column} name={column}