diff options
| author | Md Saban <45597394+mdsaban@users.noreply.github.com> | 2024-06-22 21:20:14 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-22 16:50:14 +0100 |
| commit | ccfff6b1954030a273b0612f3772ec00a82422c8 (patch) | |
| tree | 29b9c9ce9828ead27ff09aa5ac3b1e7698c87fd8 /apps/web/components/dashboard | |
| parent | 16f21bf9ee747a4fc8fd235eee5c0348d355aae2 (diff) | |
| download | karakeep-ccfff6b1954030a273b0612f3772ec00a82422c8.tar.zst | |
fix(web): Fix save action on empty card. Fixes #225 (#243)
* fix: Empty item save action
* fix: resolve comments
* chore: prettier
Diffstat (limited to 'apps/web/components/dashboard')
| -rw-r--r-- | apps/web/components/dashboard/bookmarks/EditorCard.tsx | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/apps/web/components/dashboard/bookmarks/EditorCard.tsx b/apps/web/components/dashboard/bookmarks/EditorCard.tsx index 3006a964..a1055e8e 100644 --- a/apps/web/components/dashboard/bookmarks/EditorCard.tsx +++ b/apps/web/components/dashboard/bookmarks/EditorCard.tsx @@ -13,7 +13,7 @@ import { useBookmarkLayout, useBookmarkLayoutSwitch, } from "@/lib/userLocalSettings/bookmarksLayout"; -import { cn } from "@/lib/utils"; +import { cn, getOS } from "@/lib/utils"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import { z } from "zod"; @@ -123,6 +123,7 @@ export default function EditorCard({ className }: { className?: string }) { const onSubmit: SubmitHandler<z.infer<typeof formSchema>> = (data) => { const text = data.text.trim(); + if (!text.length) return; try { tryToImportUrls(text); } catch (e) { @@ -162,12 +163,14 @@ export default function EditorCard({ className }: { className?: string }) { } }; + const OS = getOS(); + return ( <Form {...form}> <form className={cn( className, - "flex flex-col gap-2 rounded-xl bg-card p-4", + "relative flex flex-col gap-2 rounded-xl bg-card p-4", cardHeight, )} onSubmit={form.handleSubmit(onSubmit, onError)} @@ -187,7 +190,7 @@ export default function EditorCard({ className }: { className?: string }) { ref={inputRef} disabled={isPending} className={cn( - "h-full w-full border-none text-lg focus-visible:ring-0", + "h-full w-full border-none p-0 text-lg focus-visible:ring-0", { "resize-none": bookmarkLayout !== "list" }, )} placeholder={ @@ -216,7 +219,7 @@ export default function EditorCard({ className }: { className?: string }) { {form.formState.dirtyFields.text ? demoMode ? "Submissions are disabled" - : "Press ⌘ + Enter to Save" + : `Save (${OS === "macos" ? "⌘" : "Ctrl"} + Enter)` : "Save"} </ActionButton> |
