Connect, collaborate, and grow with a community of TypeScript developers
UPDATE solutions form (#1048)
Mark Khoo36b7d52f3118
diff --git a/apps/web/src/app/[locale]/challenge/[slug]/solutions/_components/solution-editor.tsx b/apps/web/src/app/[locale]/challenge/[slug]/solutions/_components/solution-editor.tsxindex ec453514..59fb2258 100644--- a/apps/web/src/app/[locale]/challenge/[slug]/solutions/_components/solution-editor.tsx+++ b/apps/web/src/app/[locale]/challenge/[slug]/solutions/_components/solution-editor.tsx@@ -87,7 +87,7 @@ export function SolutionEditor({ dismiss, challenge }: Props) {return (<Form {...form}><form className="relative flex h-full flex-col" onSubmit={form.handleSubmit(onSubmit)}>- <div className="bg-background/90 dark:bg-muted/90 sticky right-0 top-0 z-10 flex w-full items-center justify-between gap-2 border-b border-zinc-300 bg-opacity-20 p-1 pr-2 backdrop-blur-sm dark:border-zinc-700">+ <div className="bg-background/90 dark:bg-muted/90 sticky right-0 top-0 z-10 flex w-full items-start justify-between gap-2 border-b border-zinc-300 bg-opacity-20 p-1 pr-2 backdrop-blur-sm dark:border-zinc-700"><div className="flex-1"><FormFieldcontrol={form.control}@@ -107,13 +107,13 @@ export function SolutionEditor({ dismiss, challenge }: Props) {/></div><Button- className="h-8 rounded-lg bg-white px-3 py-2 text-black hover:bg-zinc-200 focus-visible:bg-zinc-200 dark:bg-zinc-800 dark:text-zinc-300 dark:hover:bg-zinc-700 dark:focus-visible:bg-zinc-700"+ className="my-1 h-8 rounded-lg bg-white px-3 py-2 text-black hover:bg-zinc-200 focus-visible:bg-zinc-200 dark:bg-zinc-800 dark:text-zinc-300 dark:hover:bg-zinc-700 dark:focus-visible:bg-zinc-700"onClick={dismiss}type="button">Cancel</Button>- <Button className="h-8 rounded-lg px-3 py-2" type="submit">+ <Button className="my-1 h-8 rounded-lg px-3 py-2" type="submit">Post</Button></div>diff --git a/apps/web/src/app/[locale]/challenge/_components/comments/comment-input.tsx b/apps/web/src/app/[locale]/challenge/_components/comments/comment-input.tsxindex 59c6504d..bf17ab78 100644--- a/apps/web/src/app/[locale]/challenge/_components/comments/comment-input.tsx+++ b/apps/web/src/app/[locale]/challenge/_components/comments/comment-input.tsx@@ -74,46 +74,48 @@ export function CommentInput({ mode, onCancel, onChange, value, placeholder, onS};return (- <div className="relative flex flex-col rounded-xl rounded-br-lg bg-neutral-100 backdrop-blur-sm dark:border-zinc-700 dark:bg-zinc-700/90">+ <div className="relative flex flex-col">{commentMode === 'editor' && (- <Form {...form}>- <FormField- control={form.control}- name="text"- render={({ field }) => (- <FormItem>- <Textarea- disabled={!session?.user}- autoFocus- className="resize-none border-0 px-3 py-2 focus-visible:ring-0 md:max-h-[calc(100vh_-_232px)]"- onChange={(e) => {- field.onChange(e);- onChange(e.target.value);- form.trigger();- }}- onKeyDown={(e) => {- if (isSubmitting) {- e.preventDefault();- return;+ <div className="rounded-xl rounded-br-lg bg-neutral-100 backdrop-blur-sm dark:border-zinc-700 dark:bg-zinc-700/90">+ <Form {...form}>+ <FormField+ control={form.control}+ name="text"+ render={({ field }) => (+ <FormItem>+ <Textarea+ disabled={!session?.user}+ autoFocus+ className="resize-none border-0 px-3 py-2 focus-visible:ring-0 md:max-h-[calc(100vh_-_232px)]"+ onChange={(e) => {+ field.onChange(e);+ onChange(e.target.value);+ form.trigger();+ }}+ onKeyDown={(e) => {+ if (isSubmitting) {+ e.preventDefault();+ return;+ }+ if (e.key === 'Enter' && e.shiftKey) {+ form.handleSubmit(handleEnterKey)();+ e.preventDefault();+ }+ }}+ placeholder={+ placeholder ?? !session?.user+ ? 'You need to be logged in to comment.'+ : 'Enter your comment here.'}- if (e.key === 'Enter' && e.shiftKey) {- form.handleSubmit(handleEnterKey)();- e.preventDefault();- }- }}- placeholder={- placeholder ?? !session?.user- ? 'You need to be logged in to comment.'- : 'Enter your comment here.'- }- ref={textAreaRef}- value={value}- />- <FormMessage className="absolute h-8 pl-3 leading-8" />- </FormItem>- )}- />- </Form>+ ref={textAreaRef}+ value={value}+ />+ <FormMessage className="absolute h-8 pl-3 leading-8" />+ </FormItem>+ )}+ />+ </Form>+ </div>)}{commentMode === 'preview' && (<div className="min-h-[5rem] overflow-y-auto break-words px-3 pt-2 text-sm md:max-h-[calc(100vh_-_232px)]">