From edfee2c35dbe99be2e1a8b7d9868ca9d6e8d0a7d Mon Sep 17 00:00:00 2001 From: andrzej Date: Tue, 2 Jul 2024 23:01:26 +0200 Subject: [PATCH] make inputs work with Enter --- prisma/dev.db | Bin 69632 -> 69632 bytes src/app/story/columns.tsx | 4 +--- src/app/tailwind.css | 8 ++++++++ src/app/ui/forms/pub.tsx | 7 ------- src/app/ui/tables/inputs/numberInput.tsx | 3 ++- src/app/ui/tables/inputs/textInput.tsx | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/prisma/dev.db b/prisma/dev.db index 9edcab751a023cfef1fcbcb20798f9152487a4c9..eb7bb0b5d6ae966d2cc9b2125bafa436c9ce0a4d 100644 GIT binary patch delta 131 zcmZozz|ydQWr8##$3z)tMvjdM%j;P=`Q`anZ02cr$Hy2p`FEd+wG<-@1CuG!JNJzI z;t~bNoXpg`Vuk!P1>eM?Vg*mn;+z~|d7uh)mb#FPR0Y4(a)scM{Gv+!^9(_gqx$_M g#hHMz`phlC1&PV23So)41(`*uAf1~J_S-iA07;A})c^nh delta 131 zcmZozz|ydQWr8##^F$eEM&^wP%j;QL`IGoNHuE&R<71Sc{JT%Znm>#|fx|H*BUQmE zCqGFcJwLTrp(I}+D6=dzFC{ex2!!QX7?{+VUx3v3rIsrMm*f{!^3P-7nH<&cC+VJ% bUtFT#4%HT1keHmR;FzA6nYa01zkLG$ok%Mk diff --git a/src/app/story/columns.tsx b/src/app/story/columns.tsx index dca5bdf..2beee52 100644 --- a/src/app/story/columns.tsx +++ b/src/app/story/columns.tsx @@ -4,12 +4,10 @@ import { StoryWithGenres } from "./page" import { ArrowUpDown } from "lucide-react" import { Button } from "@/components/ui/button" import GenreBadges from "app/ui/genreBadges" -import { actions } from "app/ui/tables/actions" -import { TextInputCell } from "app/ui/tables/inputs/textInput" import { selectCol } from "app/ui/tables/selectColumn" import NumberInputCell from "app/ui/tables/inputs/numberInput" import { formSchema } from "app/ui/forms/story" - +import { TextInputCell } from "app/ui/tables/inputs/textInput" const columnHelper = createColumnHelper() export const columns: ColumnDef[] = [ diff --git a/src/app/tailwind.css b/src/app/tailwind.css index c0fc71c..0ff5be1 100644 --- a/src/app/tailwind.css +++ b/src/app/tailwind.css @@ -959,6 +959,14 @@ body { width: 100vw; } +.w-8 { + width: 2rem; +} + +.w-16 { + width: 4rem; +} + .min-w-\[8rem\] { min-width: 8rem; } diff --git a/src/app/ui/forms/pub.tsx b/src/app/ui/forms/pub.tsx index 0ad60f6..43bd326 100644 --- a/src/app/ui/forms/pub.tsx +++ b/src/app/ui/forms/pub.tsx @@ -3,7 +3,6 @@ import { z } from "zod" import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" -import { Button } from "@/components/ui/button" import { Form, FormControl, @@ -16,12 +15,6 @@ import { import { Input } from "@/components/ui/input" import { toast } from "@/components/ui/use-toast" -import { - Popover, - PopoverContent, -} from "@/components/ui/popover" -import GenresTrigger from "./genresTrigger" -import GenreCheckbox from "./genreCheckbox" import { randomPublicationTitle } from "app/lib/shortStoryTitleGenerator" import { ComponentProps } from "react" import { Genre } from "@prisma/client" diff --git a/src/app/ui/tables/inputs/numberInput.tsx b/src/app/ui/tables/inputs/numberInput.tsx index 0a8517d..0b495cb 100644 --- a/src/app/ui/tables/inputs/numberInput.tsx +++ b/src/app/ui/tables/inputs/numberInput.tsx @@ -64,7 +64,7 @@ export default function NumberInputCell(props: CellContext) { className="w-full h-fit flex items-center justify-center" tabIndex={0} onKeyDown={e => { - if (e.code === "Space" && !isActive) { + if (e.code === "Enter" && !isActive) { e.preventDefault() setIsActive(true) } @@ -84,6 +84,7 @@ export default function NumberInputCell(props: CellContext) { ) { }, }) - function onSubmit(value: z.infer) { + async function onSubmit(value: z.infer) { toast({ title: "You submitted the following values:", description: ( @@ -35,7 +35,7 @@ export function TextInputCell(props: CellContext) { ), }) - updateField({ + const res = await updateField({ id, table, string: value[column], @@ -62,7 +62,7 @@ export function TextInputCell(props: CellContext) { className="w-full h-fit flex items-center justify-center" tabIndex={0} onKeyDown={e => { - if (e.code === "Space" && !isActive) { + if (e.code === "Enter" && !isActive) { e.preventDefault() setIsActive(true) }