Skip to content

Commit

Permalink
fix(Modal): pass optional event handlers to all onClick functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sjschlapbach committed Jan 21, 2025
1 parent 80ed5ec commit f7e1449
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/design-system/src/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export interface ModalProps {
hideCloseButton?: boolean
asPortal?: boolean

onClose: () => void
onNext?: () => void
onOpenChange?: () => void
onPrev?: () => void
onClose: (e?: React.MouseEvent<HTMLButtonElement>) => void
onNext?: (e?: React.MouseEvent<HTMLButtonElement>) => void
onOpenChange?: (e?: React.MouseEvent<HTMLButtonElement>) => void
onPrev?: (e?: React.MouseEvent<HTMLButtonElement>) => void
onPrimaryAction?: React.ReactNode
onSecondaryAction?: React.ReactNode
}
Expand Down Expand Up @@ -154,9 +154,9 @@ export function Modal({
: 'h-max max-h-full w-[27rem] max-w-7xl md:w-[40rem] lg:w-[55rem] xl:w-[70rem]',
className?.content
)}
onEscapeKeyDown={escapeDisabled ? undefined : onClose}
onEscapeKeyDown={escapeDisabled ? undefined : () => onClose()}
onPointerDownOutside={
onPrev || onNext || escapeDisabled ? undefined : onClose
onPrev || onNext || escapeDisabled ? undefined : () => onClose()
}
data-cy={dataContent?.cy}
data-test={dataContent?.test}
Expand Down Expand Up @@ -212,7 +212,7 @@ export function Modal({
)

return (
<RadixDialog.Root open={open} onOpenChange={onOpenChange}>
<RadixDialog.Root open={open} onOpenChange={() => onOpenChange?.()}>
{trigger && (
<RadixDialog.Trigger
id={id}
Expand Down

0 comments on commit f7e1449

Please sign in to comment.