diff --git a/change/@fluentui-react-dialog-cfbd0be5-81c5-4351-9f00-8931078078c2.json b/change/@fluentui-react-dialog-cfbd0be5-81c5-4351-9f00-8931078078c2.json new file mode 100644 index 00000000000000..b3d534f419827a --- /dev/null +++ b/change/@fluentui-react-dialog-cfbd0be5-81c5-4351-9f00-8931078078c2.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "feat: removes aria-haspopup", + "packageName": "@fluentui/react-dialog", + "email": "bernardo.sunderhus@gmail.com", + "dependentChangeType": "patch" +} diff --git a/packages/react-components/react-dialog/src/components/Dialog/Dialog.cy.tsx b/packages/react-components/react-dialog/src/components/Dialog/Dialog.cy.tsx index 58e6e924f5b665..bc6f5d7861a3a5 100644 --- a/packages/react-components/react-dialog/src/components/Dialog/Dialog.cy.tsx +++ b/packages/react-components/react-dialog/src/components/Dialog/Dialog.cy.tsx @@ -29,6 +29,7 @@ import { dialogSurfaceSelector, dialogTriggerCloseId, dialogTriggerCloseSelector, + dialogTriggerOpenId, dialogTriggerOpenSelector, } from '../../testing/selectors'; @@ -39,7 +40,7 @@ describe('Dialog', () => { mount( - + @@ -51,7 +52,9 @@ describe('Dialog', () => { - + @@ -66,7 +69,7 @@ describe('Dialog', () => { mount( - + @@ -78,7 +81,9 @@ describe('Dialog', () => { - + @@ -93,7 +98,7 @@ describe('Dialog', () => { mount( - + @@ -122,7 +127,7 @@ describe('Dialog', () => { mount( - + @@ -143,7 +148,7 @@ describe('Dialog', () => { mount( - + @@ -182,7 +187,7 @@ describe('Dialog', () => { //eslint-disable-next-line react/jsx-no-bind setOpen(data.open)}> - + @@ -212,7 +217,7 @@ describe('Dialog', () => { mount( - + @@ -270,7 +275,7 @@ describe('Dialog', () => { mount( - + @@ -282,7 +287,9 @@ describe('Dialog', () => { - + @@ -298,7 +305,7 @@ describe('Dialog', () => { mount( - + Dialog title @@ -309,7 +316,9 @@ describe('Dialog', () => { - + @@ -325,7 +334,7 @@ describe('Dialog', () => { mount( - + @@ -337,7 +346,9 @@ describe('Dialog', () => { - + @@ -353,7 +364,7 @@ describe('Dialog', () => { mount( - + @@ -365,7 +376,9 @@ describe('Dialog', () => { - + @@ -382,7 +395,7 @@ describe('Dialog', () => { mount( - + @@ -394,7 +407,9 @@ describe('Dialog', () => { - + @@ -410,7 +425,7 @@ describe('Dialog', () => { mount( - + @@ -422,7 +437,9 @@ describe('Dialog', () => { - + diff --git a/packages/react-components/react-dialog/src/components/Dialog/useDialog.ts b/packages/react-components/react-dialog/src/components/Dialog/useDialog.ts index 8a96386c788a25..4d0a75e859ab77 100644 --- a/packages/react-components/react-dialog/src/components/Dialog/useDialog.ts +++ b/packages/react-components/react-dialog/src/components/Dialog/useDialog.ts @@ -54,7 +54,6 @@ export const useDialog_unstable = (props: DialogProps): DialogState => { content: open ? content : null, trigger, requestOpenChange, - dialogContentId: useId('dialog-content-'), dialogTitleId: useId('dialog-title-'), isNestedDialog: useHasParentContext(DialogContext), dialogRef: focusRef, diff --git a/packages/react-components/react-dialog/src/components/Dialog/useDialogContextValues.ts b/packages/react-components/react-dialog/src/components/Dialog/useDialogContextValues.ts index 0cf153ca7971ab..7c46e25ac788af 100644 --- a/packages/react-components/react-dialog/src/components/Dialog/useDialogContextValues.ts +++ b/packages/react-components/react-dialog/src/components/Dialog/useDialogContextValues.ts @@ -2,7 +2,7 @@ import type { DialogContextValue, DialogSurfaceContextValue } from '../../contex import type { DialogContextValues, DialogState } from './Dialog.types'; export function useDialogContextValues_unstable(state: DialogState): DialogContextValues { - const { modalType, open, dialogContentId, dialogRef, dialogTitleId, isNestedDialog, requestOpenChange } = state; + const { modalType, open, dialogRef, dialogTitleId, isNestedDialog, requestOpenChange } = state; /** * This context is created with "@fluentui/react-context-selector", @@ -12,7 +12,6 @@ export function useDialogContextValues_unstable(state: DialogState): DialogConte open, modalType, dialogRef, - dialogContentId, dialogTitleId, isNestedDialog, requestOpenChange, diff --git a/packages/react-components/react-dialog/src/components/DialogContent/useDialogContent.ts b/packages/react-components/react-dialog/src/components/DialogContent/useDialogContent.ts index 14e3520fbf88c7..b188629898581a 100644 --- a/packages/react-components/react-dialog/src/components/DialogContent/useDialogContent.ts +++ b/packages/react-components/react-dialog/src/components/DialogContent/useDialogContent.ts @@ -1,6 +1,5 @@ import * as React from 'react'; import { getNativeElementProps } from '@fluentui/react-utilities'; -import { useDialogContext_unstable } from '../../contexts'; import { DialogContentProps, DialogContentState } from './DialogContent.types'; /** @@ -16,14 +15,12 @@ export const useDialogContent_unstable = ( props: DialogContentProps, ref: React.Ref, ): DialogContentState => { - const dialogContentId = useDialogContext_unstable(ctx => ctx.dialogContentId); return { components: { root: 'div', }, root: getNativeElementProps(props.as ?? 'div', { ref, - id: dialogContentId, ...props, }), }; diff --git a/packages/react-components/react-dialog/src/components/DialogSurface/useDialogSurface.ts b/packages/react-components/react-dialog/src/components/DialogSurface/useDialogSurface.ts index 0505beb29c3c42..3c2d4fa80cbf15 100644 --- a/packages/react-components/react-dialog/src/components/DialogSurface/useDialogSurface.ts +++ b/packages/react-components/react-dialog/src/components/DialogSurface/useDialogSurface.ts @@ -35,7 +35,6 @@ export const useDialogSurface_unstable = ( const open = useDialogContext_unstable(ctx => ctx.open); const requestOpenChange = useDialogContext_unstable(ctx => ctx.requestOpenChange); const dialogTitleID = useDialogContext_unstable(ctx => ctx.dialogTitleId); - const dialogContentId = useDialogContext_unstable(ctx => ctx.dialogContentId); const handledBackdropClick = useEventCallback((event: React.MouseEvent) => { if (isResolvedShorthand(props.backdrop)) { @@ -83,7 +82,6 @@ export const useDialogSurface_unstable = ( tabIndex: -1, // https://github.com/microsoft/fluentui/issues/25150 'aria-modal': modalType !== 'non-modal', role: modalType === 'alert' ? 'alertdialog' : 'dialog', - 'aria-describedby': dialogContentId, 'aria-labelledby': props['aria-label'] ? undefined : dialogTitleID, ...props, ...modalAttributes, diff --git a/packages/react-components/react-dialog/src/components/DialogTitle/DialogTitle.cy.tsx b/packages/react-components/react-dialog/src/components/DialogTitle/DialogTitle.cy.tsx index 0a5c99ad75cd54..c5db62f134a3bf 100644 --- a/packages/react-components/react-dialog/src/components/DialogTitle/DialogTitle.cy.tsx +++ b/packages/react-components/react-dialog/src/components/DialogTitle/DialogTitle.cy.tsx @@ -14,7 +14,7 @@ import { DialogTrigger, } from '@fluentui/react-dialog'; import { Button } from '@fluentui/react-components'; -import { dialogActionSelector, dialogTriggerOpenSelector } from '../../testing/selectors'; +import { dialogActionSelector, dialogTriggerOpenId, dialogTriggerOpenSelector } from '../../testing/selectors'; const mount = (element: JSX.Element) => mountBase({element}); @@ -24,7 +24,7 @@ describe('DialogTitle', () => { mount( - + @@ -53,7 +53,7 @@ describe('DialogTitle', () => { mount( - + @@ -82,7 +82,7 @@ describe('DialogTitle', () => { mount( - + diff --git a/packages/react-components/react-dialog/src/components/DialogTrigger/DialogTrigger.test.tsx b/packages/react-components/react-dialog/src/components/DialogTrigger/DialogTrigger.test.tsx index 15a2654afcc6d8..227c5ac9a84f4d 100644 --- a/packages/react-components/react-dialog/src/components/DialogTrigger/DialogTrigger.test.tsx +++ b/packages/react-components/react-dialog/src/components/DialogTrigger/DialogTrigger.test.tsx @@ -56,7 +56,7 @@ describe('DialogTrigger', () => { expect(ref.mock.calls[0]).toMatchInlineSnapshot(` Array [ - + setOpen(data.open)}> diff --git a/packages/react-components/react-dialog/stories/Dialog/DialogWithForm.md b/packages/react-components/react-dialog/stories/Dialog/DialogWithForm.md index 53cea607346b46..400fe6206dfbd8 100644 --- a/packages/react-components/react-dialog/stories/Dialog/DialogWithForm.md +++ b/packages/react-components/react-dialog/stories/Dialog/DialogWithForm.md @@ -1,5 +1,3 @@ Having a `form` inside the `Dialog` its quite simple, you simply add a `
` element between `DialogSurface` and `DialogBody` to ensure all the content between them are properly wrapped inside the formulary. This allows a button inside `DialogActions` to be properly used as submission button. > Keep in mind that controlling the `open` state of the `Dialog` might be ideal in this scenario, since validation and submission are possibly synchronous activities. For example, closing the `Dialog` only after the submission is successful would require control of the `open` state, to properly set `open` to `false` only once the submission has succeeded. - -> ⚠️ Don't forget to set `aria-describedby={undefined}` for `DialogSurface` to ensure the formulary is not automatically narrated by screen readers.