Autofocus inputs (#486)
This commit is contained in:
parent
affd387d03
commit
cab9fddecc
3 changed files with 9 additions and 6 deletions
|
|
@ -30,6 +30,7 @@ export function AuthForm({
|
||||||
placeholder="user@acme.com"
|
placeholder="user@acme.com"
|
||||||
autoComplete="email"
|
autoComplete="email"
|
||||||
required
|
required
|
||||||
|
autoFocus
|
||||||
defaultValue={defaultEmail}
|
defaultValue={defaultEmail}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -254,6 +254,7 @@ export function MultimodalInput({
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
rows={3}
|
rows={3}
|
||||||
|
autoFocus
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (event.key === 'Enter' && !event.shiftKey) {
|
if (event.key === 'Enter' && !event.shiftKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,19 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useFormStatus } from "react-dom";
|
import { useFormStatus } from 'react-dom';
|
||||||
|
|
||||||
import { LoaderIcon } from "@/components/custom/icons";
|
import { LoaderIcon } from '@/components/custom/icons';
|
||||||
|
|
||||||
import { Button } from "../ui/button";
|
import { Button } from '../ui/button';
|
||||||
|
|
||||||
export function SubmitButton({ children }: { children: React.ReactNode }) {
|
export function SubmitButton({ children }: { children: React.ReactNode }) {
|
||||||
const { pending } = useFormStatus();
|
const { pending } = useFormStatus();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
type={pending ? "button" : "submit"}
|
type={pending ? 'button' : 'submit'}
|
||||||
aria-disabled={pending}
|
aria-disabled={pending}
|
||||||
|
disabled={pending}
|
||||||
className="relative"
|
className="relative"
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|
@ -22,7 +23,7 @@ export function SubmitButton({ children }: { children: React.ReactNode }) {
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
<span aria-live="polite" className="sr-only" role="status">
|
<span aria-live="polite" className="sr-only" role="status">
|
||||||
{pending ? "Loading" : "Submit form"}
|
{pending ? 'Loading' : 'Submit form'}
|
||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue