Skip to content

Commit

Permalink
fix dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
MrFlashAccount committed May 22, 2024
1 parent dabdf61 commit ba0620e
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import * as aria from '#/components/aria'
import * as ariaComponents from '#/components/AriaComponents'
import * as portal from '#/components/Portal'

import * as mergeRefs from '#/utilities/mergeRefs'

import type * as types from './types'
import * as variants from './variants'

Expand Down Expand Up @@ -107,7 +109,23 @@ export function Dialog(props: types.DialogProps) {
onOpenChange={onOpenChange}
{...modalProps}
>
<aria.Dialog ref={dialogRef} className={dialogSlots.base()} {...ariaDialogProps}>
<aria.Dialog
ref={mergeRefs.mergeRefs(dialogRef, element => {
if (element) {
// This is a workaround for the `data-testid` attribute not being
// supported by the 'react-aria-components' library.
// We need to set the `data-testid` attribute on the dialog element
// so that we can use it in our tests.
// This is a temporary solution until we refactor the Dialog component
// to use `useDialog` hook from the 'react-aria-components' library.
// this will allow us to set the `data-testid` attribute on the dialog
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
element.dataset.testId = testId
}
})}
className={dialogSlots.base()}
{...ariaDialogProps}
>
{opts => (
<>
{shouldRenderTitle && (
Expand Down

0 comments on commit ba0620e

Please sign in to comment.