You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying to change the site's example code (below) to remove the auto focus on the first available element. I've tried adding onOpenAutoFocus={(e) => e.preventDefault()} to the DialogPrimitive.Content component, but that didn't have any affect. Normally this wouldn't be a issue but in my real code I have two datetime pickers and I don't want the first one to open automatically.
<script lang="ts">
import { Button, buttonVariants } from "$lib/components/ui/button/index.js";
import * as Dialog from "$lib/components/ui/dialog";
import { Input } from "$lib/components/ui/input/index.js";
import { Label } from "$lib/components/ui/label/index.js";
</script>
<Dialog.Root>
<Dialog.Trigger class={buttonVariants({ variant: "outline" })}>Edit Profile</Dialog.Trigger>
<Dialog.Content class="sm:max-w-[425px]">
<Dialog.Header>
<Dialog.Title>Edit profile</Dialog.Title>
<Dialog.Description>
Make changes to your profile here. Click save when you're done.
</Dialog.Description>
</Dialog.Header>
<div class="grid gap-4 py-4">
<div class="grid grid-cols-4 items-center gap-4">
<Label for="name" class="text-right">Name</Label>
<Input id="name" value="Pedro Duarte" class="col-span-3" />
</div>
<div class="grid grid-cols-4 items-center gap-4">
<Label for="username" class="text-right">Username</Label>
<Input id="username" value="@peduarte" class="col-span-3" />
</div>
</div>
<Dialog.Footer>
<Button type="submit">Save changes</Button>
</Dialog.Footer>
</Dialog.Content>
</Dialog.Root>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all!,
I've been trying to change the site's example code (below) to remove the auto focus on the first available element. I've tried adding
onOpenAutoFocus={(e) => e.preventDefault()}
to theDialogPrimitive.Content
component, but that didn't have any affect. Normally this wouldn't be a issue but in my real code I have two datetime pickers and I don't want the first one to open automatically.Thanks Gary
Beta Was this translation helpful? Give feedback.
All reactions