Skip to content

Commit

Permalink
bugfix: moves handleBackdropClick from defaultProps to an override (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bsunderhus authored Jul 20, 2023
1 parent 2adf9de commit 21d69b7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "bugfix: moves handleBackdropClick from defaultProps to an override ",
"packageName": "@fluentui/react-dialog",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const useDialogSurface_unstable = (
props: DialogSurfaceProps,
ref: React.Ref<DialogSurfaceElement>,
): DialogSurfaceState => {
const { backdrop, as } = props;
const modalType = useDialogContext_unstable(ctx => ctx.modalType);
const modalAttributes = useDialogContext_unstable(ctx => ctx.modalAttributes);
const dialogRef = useDialogContext_unstable(ctx => ctx.dialogRef);
Expand Down Expand Up @@ -59,19 +58,24 @@ export const useDialogSurface_unstable = (
}
});

const backdrop = resolveShorthand(props.backdrop, {
required: open && modalType !== 'non-modal',
defaultProps: {
'aria-hidden': 'true',
},
});

if (backdrop) {
backdrop.onClick = handledBackdropClick;
}

return {
components: {
backdrop: 'div',
root: 'div',
},
backdrop: resolveShorthand(backdrop, {
required: open && modalType !== 'non-modal',
defaultProps: {
'aria-hidden': 'true',
onClick: handledBackdropClick,
},
}),
root: getNativeElementProps(as ?? 'div', {
backdrop,
root: getNativeElementProps(props.as ?? 'div', {
tabIndex: -1, // https:/microsoft/fluentui/issues/25150
'aria-modal': modalType !== 'non-modal',
role: modalType === 'alert' ? 'alertdialog' : 'dialog',
Expand Down

0 comments on commit 21d69b7

Please sign in to comment.