diff --git a/change/@fluentui-react-dialog-4035cb74-88c2-4411-b3ac-9e1e049e2d69.json b/change/@fluentui-react-dialog-4035cb74-88c2-4411-b3ac-9e1e049e2d69.json new file mode 100644 index 0000000000000..ad3c8bb736707 --- /dev/null +++ b/change/@fluentui-react-dialog-4035cb74-88c2-4411-b3ac-9e1e049e2d69.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "bugfix: DialogTitle root as h2 by default", + "packageName": "@fluentui/react-dialog", + "email": "bernardo.sunderhus@gmail.com", + "dependentChangeType": "patch" +} diff --git a/packages/react-components/react-dialog/etc/react-dialog.api.md b/packages/react-components/react-dialog/etc/react-dialog.api.md index f458bfff86dd2..220da51f12feb 100644 --- a/packages/react-components/react-dialog/etc/react-dialog.api.md +++ b/packages/react-components/react-dialog/etc/react-dialog.api.md @@ -150,7 +150,7 @@ export type DialogTitleProps = ComponentProps; // @public (undocumented) export type DialogTitleSlots = { - root: Slot<'div', 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'>; + root: Slot<'h2', 'h1' | 'h3' | 'h4' | 'h5' | 'h6' | 'div'>; action?: Slot<'div'>; }; diff --git a/packages/react-components/react-dialog/src/components/DialogTitle/DialogTitle.types.ts b/packages/react-components/react-dialog/src/components/DialogTitle/DialogTitle.types.ts index 5369a1bff9032..7388cb8d1e36c 100644 --- a/packages/react-components/react-dialog/src/components/DialogTitle/DialogTitle.types.ts +++ b/packages/react-components/react-dialog/src/components/DialogTitle/DialogTitle.types.ts @@ -2,9 +2,10 @@ import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utili export type DialogTitleSlots = { /** - * By default this is a div, but can be a heading. + * By default this is a h2, but can be any heading or div, + * if `div` is provided do not forget to also provide proper `role="heading"` and `aria-level` attributes */ - root: Slot<'div', 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'>; + root: Slot<'h2', 'h1' | 'h3' | 'h4' | 'h5' | 'h6' | 'div'>; /** * By default a Dialog with modalType='non-modal' will have a close button action */ diff --git a/packages/react-components/react-dialog/src/components/DialogTitle/__snapshots__/DialogTitle.test.tsx.snap b/packages/react-components/react-dialog/src/components/DialogTitle/__snapshots__/DialogTitle.test.tsx.snap index c32d25e64a3c6..d675f3663feda 100644 --- a/packages/react-components/react-dialog/src/components/DialogTitle/__snapshots__/DialogTitle.test.tsx.snap +++ b/packages/react-components/react-dialog/src/components/DialogTitle/__snapshots__/DialogTitle.test.tsx.snap @@ -2,10 +2,10 @@ exports[`DialogTitle renders a default state 1`] = `
-
Default DialogTitle -
+
`; diff --git a/packages/react-components/react-dialog/src/components/DialogTitle/useDialogTitle.tsx b/packages/react-components/react-dialog/src/components/DialogTitle/useDialogTitle.tsx index df669cb699cc3..0e08fdc625575 100644 --- a/packages/react-components/react-dialog/src/components/DialogTitle/useDialogTitle.tsx +++ b/packages/react-components/react-dialog/src/components/DialogTitle/useDialogTitle.tsx @@ -23,10 +23,10 @@ export const useDialogTitle_unstable = (props: DialogTitleProps, ref: React.Ref< return { components: { - root: 'div', + root: 'h2', action: 'div', }, - root: getNativeElementProps(as ?? 'div', { + root: getNativeElementProps(as ?? 'h2', { ref, id: useDialogContext_unstable(ctx => ctx.dialogTitleId), ...props, diff --git a/packages/react-components/react-dialog/src/components/DialogTitle/useDialogTitleStyles.ts b/packages/react-components/react-dialog/src/components/DialogTitle/useDialogTitleStyles.ts index 5b334a662eda6..a6c74cef3b6ab 100644 --- a/packages/react-components/react-dialog/src/components/DialogTitle/useDialogTitleStyles.ts +++ b/packages/react-components/react-dialog/src/components/DialogTitle/useDialogTitleStyles.ts @@ -17,6 +17,7 @@ const useStyles = makeStyles({ root: { ...typographyStyles.subtitle1, ...shorthands.gridArea(TITLE_GRID_AREA), + ...shorthands.margin(0), }, rootWithoutCloseButton: { ...shorthands.gridArea(TITLE_GRID_AREA, TITLE_GRID_AREA, TITLE_ACTION_GRID_AREA, TITLE_ACTION_GRID_AREA),