Skip to content

Commit 50a27e2

Browse files
authoredMar 18, 2025··
refactor(clerk-js): Default <Drawer.Confirmation /> to alertdialog role (#5383)
1 parent 8cbb7c6 commit 50a27e2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed
 

‎.changeset/fast-rocks-repeat.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Default `<Drawer.Confirmation />` to `alertdialog` role.

‎packages/clerk-js/src/ui/elements/Drawer.tsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useSafeLayoutEffect } from '@clerk/shared/react/index';
2-
import type { UseDismissProps, UseFloatingOptions } from '@floating-ui/react';
2+
import type { UseDismissProps, UseFloatingOptions, UseRoleProps } from '@floating-ui/react';
33
import {
44
FloatingFocusManager,
55
FloatingPortal,
@@ -411,10 +411,11 @@ interface ConfirmationProps {
411411
onOpenChange: (open: boolean) => void;
412412
children: React.ReactNode;
413413
actionsSlot: React.ReactNode;
414+
roleProps?: UseRoleProps;
414415
}
415416

416417
const Confirmation = React.forwardRef<HTMLDivElement, ConfirmationProps>(
417-
({ open, onOpenChange, children, actionsSlot }, ref) => {
418+
({ open, onOpenChange, children, actionsSlot, roleProps }, ref) => {
418419
const prefersReducedMotion = usePrefersReducedMotion();
419420
const { animations: layoutAnimations } = useAppearance().parsedLayout;
420421
const isMotionSafe = !prefersReducedMotion && layoutAnimations === true;
@@ -425,6 +426,11 @@ const Confirmation = React.forwardRef<HTMLDivElement, ConfirmationProps>(
425426
transform: false,
426427
strategy: 'absolute',
427428
});
429+
const { getFloatingProps } = useInteractions([
430+
useClick(context),
431+
useDismiss(context),
432+
useRole(context, { role: 'alertdialog', ...roleProps }),
433+
]);
428434

429435
const mergedRefs = useMergeRefs([ref, refs.setFloating]);
430436

@@ -450,8 +456,6 @@ const Confirmation = React.forwardRef<HTMLDivElement, ConfirmationProps>(
450456
duration: isMotionSafe ? transitionDurationValues.drawer : 0,
451457
});
452458

453-
const { getFloatingProps } = useInteractions([useClick(context), useDismiss(context), useRole(context)]);
454-
455459
if (!isMounted) return null;
456460

457461
return (
@@ -471,7 +475,6 @@ const Confirmation = React.forwardRef<HTMLDivElement, ConfirmationProps>(
471475
modal
472476
outsideElementsInert
473477
initialFocus={refs.floating}
474-
visuallyHiddenDismiss
475478
>
476479
<Box
477480
ref={mergedRefs}

0 commit comments

Comments
 (0)
Please sign in to comment.