diff --git a/change/@fluentui-react-dialog-bbb01d69-5227-40c3-aaf3-053f1af35f0d.json b/change/@fluentui-react-dialog-bbb01d69-5227-40c3-aaf3-053f1af35f0d.json new file mode 100644 index 0000000000000..d1519e7774f99 --- /dev/null +++ b/change/@fluentui-react-dialog-bbb01d69-5227-40c3-aaf3-053f1af35f0d.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "chore: cleanups in types", + "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 39d3c6cc52e98..60c24a2da5ecb 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 const DialogTitle: ForwardRefComponent; export const dialogTitleClassNames: SlotClassNames; // @public -export type DialogTitleProps = ComponentProps & {}; +export type DialogTitleProps = ComponentProps; // @public (undocumented) export type DialogTitleSlots = { diff --git a/packages/react-components/react-dialog/src/components/Dialog/Dialog.types.ts b/packages/react-components/react-dialog/src/components/Dialog/Dialog.types.ts index 5cad33153afaf..f24c7c59eaa6c 100644 --- a/packages/react-components/react-dialog/src/components/Dialog/Dialog.types.ts +++ b/packages/react-components/react-dialog/src/components/Dialog/Dialog.types.ts @@ -38,7 +38,8 @@ export type DialogModalType = 'modal' | 'non-modal' | 'alert'; * Callback fired when the component changes value from open state. * * @param event - a React's Synthetic event or a KeyboardEvent in case of `documentEscapeKeyDown` - * @param data - A data object with relevant information, such as open value and type + * @param data - A data object with relevant information, + * such as open value and type of interaction that created the event */ export type DialogOpenChangeEventHandler = (event: DialogOpenChangeEvent, data: DialogOpenChangeData) => void; @@ -81,6 +82,13 @@ export type DialogProps = ComponentProps> & { * @default false */ defaultOpen?: boolean; + /** + * Callback fired when the component changes value from open state. + * + * @param event - a React's Synthetic event or a KeyboardEvent in case of `documentEscapeKeyDown` + * @param data - A data object with relevant information, + * such as open value and type of interaction that created the event + */ onOpenChange?: DialogOpenChangeEventHandler; /** * Can contain two children including {@link DialogTrigger} and {@link DialogSurface}. 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 3c522f5bd47b3..5369a1bff9032 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 @@ -14,7 +14,7 @@ export type DialogTitleSlots = { /** * DialogTitle Props */ -export type DialogTitleProps = ComponentProps & {}; +export type DialogTitleProps = ComponentProps; /** * State used in rendering DialogTitle diff --git a/packages/react-components/react-dialog/src/components/DialogTrigger/DialogTrigger.types.ts b/packages/react-components/react-dialog/src/components/DialogTrigger/DialogTrigger.types.ts index 5560a281b9082..23f9d0f11bb16 100644 --- a/packages/react-components/react-dialog/src/components/DialogTrigger/DialogTrigger.types.ts +++ b/packages/react-components/react-dialog/src/components/DialogTrigger/DialogTrigger.types.ts @@ -7,8 +7,10 @@ export type DialogTriggerProps = { /** * Explicitly declare if the trigger is responsible for opening or * closing a Dialog visibility state. - * @default 'open' // if it's outside DialogSurface - * @default 'close' // if it's inside DialogSurface + * + * If `DialogTrigger` is outside `DialogSurface` then it'll be `open` by default + * + * If `DialogTrigger` is inside `DialogSurface` then it'll be `close` by default */ action?: DialogTriggerAction; /** diff --git a/packages/react-components/react-dialog/src/stories/Dialog/DialogNoFocusableElement.md b/packages/react-components/react-dialog/src/stories/Dialog/DialogNoFocusableElement.md index 2222080b4f814..224e9de6f78dc 100644 --- a/packages/react-components/react-dialog/src/stories/Dialog/DialogNoFocusableElement.md +++ b/packages/react-components/react-dialog/src/stories/Dialog/DialogNoFocusableElement.md @@ -1,3 +1,5 @@ A `Dialog` **should** always have at least one focusable element. +Some accessibility issues might happen if no focusable element is provided, like this one caught in [Talkback](https://issuetracker.google.com/issues/243456562?pli=1). + In the case no focusable element is present inside a `Dialog` the only method that would close the `Dialog` would be clicking on the `backdrop` diff --git a/packages/react-components/react-dialog/src/stories/Dialog/DialogNoFocusableElement.stories.tsx b/packages/react-components/react-dialog/src/stories/Dialog/DialogNoFocusableElement.stories.tsx index 50098fe1e2894..380ab27d6898e 100644 --- a/packages/react-components/react-dialog/src/stories/Dialog/DialogNoFocusableElement.stories.tsx +++ b/packages/react-components/react-dialog/src/stories/Dialog/DialogNoFocusableElement.stories.tsx @@ -16,7 +16,7 @@ export const NoFocusableElement = () => { Dialog Title

⛔️ A Dialog without focusable elements is not recommended!

-

⚠️ Escape key only works with native dialog

+

⛔️ Escape key doesn't work

✅ Backdrop click still works to ensure this modal can be closed

diff --git a/packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleCustomAction.md b/packages/react-components/react-dialog/src/stories/Dialog/DialogTitleCustomAction.md similarity index 100% rename from packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleCustomAction.md rename to packages/react-components/react-dialog/src/stories/Dialog/DialogTitleCustomAction.md diff --git a/packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleCustomAction.stories.tsx b/packages/react-components/react-dialog/src/stories/Dialog/DialogTitleCustomAction.stories.tsx similarity index 94% rename from packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleCustomAction.stories.tsx rename to packages/react-components/react-dialog/src/stories/Dialog/DialogTitleCustomAction.stories.tsx index 3d9320a7779e9..6889fde1e0808 100644 --- a/packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleCustomAction.stories.tsx +++ b/packages/react-components/react-dialog/src/stories/Dialog/DialogTitleCustomAction.stories.tsx @@ -4,7 +4,7 @@ import { Button } from '@fluentui/react-components'; import story from './DialogTitleCustomAction.md'; import { Dismiss24Regular } from '@fluentui/react-icons'; -export const CustomAction = () => { +export const TitleCustomAction = () => { return ( @@ -32,7 +32,7 @@ export const CustomAction = () => { ); }; -CustomAction.parameters = { +TitleCustomAction.parameters = { docs: { description: { story, diff --git a/packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleNoAction.md b/packages/react-components/react-dialog/src/stories/Dialog/DialogTitleNoAction.md similarity index 100% rename from packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleNoAction.md rename to packages/react-components/react-dialog/src/stories/Dialog/DialogTitleNoAction.md diff --git a/packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleNoAction.stories.tsx b/packages/react-components/react-dialog/src/stories/Dialog/DialogTitleNoAction.stories.tsx similarity index 94% rename from packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleNoAction.stories.tsx rename to packages/react-components/react-dialog/src/stories/Dialog/DialogTitleNoAction.stories.tsx index 8150b1d5011dc..647c9136d6666 100644 --- a/packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleNoAction.stories.tsx +++ b/packages/react-components/react-dialog/src/stories/Dialog/DialogTitleNoAction.stories.tsx @@ -11,7 +11,7 @@ import { import { Button } from '@fluentui/react-components'; import story from './DialogTitleNoAction.md'; -export const NoAction = () => { +export const TitleNoAction = () => { return ( @@ -36,7 +36,7 @@ export const NoAction = () => { ); }; -NoAction.parameters = { +TitleNoAction.parameters = { docs: { description: { story, diff --git a/packages/react-components/react-dialog/src/stories/Dialog/index.stories.tsx b/packages/react-components/react-dialog/src/stories/Dialog/index.stories.tsx index 65469b21e7333..66aed89b5d661 100644 --- a/packages/react-components/react-dialog/src/stories/Dialog/index.stories.tsx +++ b/packages/react-components/react-dialog/src/stories/Dialog/index.stories.tsx @@ -1,7 +1,8 @@ -import { Dialog } from '@fluentui/react-dialog'; +import { Dialog, DialogSurface, DialogTitle, DialogActions, DialogTrigger } from '@fluentui/react-dialog'; import descriptionMd from './DialogDescription.md'; import bestPracticesMd from './DialogBestPractices.md'; +import { ComponentMeta } from '@storybook/react'; export { Default } from './DialogDefault.stories'; export { NonModal } from './DialogNonModal.stories'; @@ -14,10 +15,18 @@ export { ChangeFocus } from './DialogChangeFocus.stories'; export { TriggerOutsideDialog } from './DialogTriggerOutsideDialog.stories'; export { CustomTrigger } from './DialogCustomTrigger.stories'; export { WithForm } from './DialogWithForm.stories'; +export { TitleCustomAction } from './DialogTitleCustomAction.stories'; +export { TitleNoAction } from './DialogTitleNoAction.stories'; export default { - title: 'Preview Components/Dialog/Dialog', + title: 'Preview Components/Dialog', component: Dialog, + subcomponents: { + DialogTrigger, + DialogSurface, + DialogTitle, + DialogActions, + }, parameters: { docs: { description: { @@ -25,4 +34,4 @@ export default { }, }, }, -}; +} as ComponentMeta; diff --git a/packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleDefault.stories.tsx b/packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleDefault.stories.tsx deleted file mode 100644 index eb9e75b432f62..0000000000000 --- a/packages/react-components/react-dialog/src/stories/DialogTitle/DialogTitleDefault.stories.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import * as React from 'react'; -import { - Dialog, - DialogTrigger, - DialogSurface, - DialogTitle, - DialogBody, - DialogActions, - DialogContent, -} from '@fluentui/react-dialog'; -import { Button } from '@fluentui/react-components'; - -export const Default = () => { - return ( - - - - - - - Dialog title - - Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam exercitationem cumque repellendus eaque - est dolor eius expedita nulla ullam? Tenetur reprehenderit aut voluptatum impedit voluptates in natus iure - cumque eaque? - - - - - - - - - - - ); -}; diff --git a/packages/react-components/react-dialog/src/stories/DialogTitle/index.stories.tsx b/packages/react-components/react-dialog/src/stories/DialogTitle/index.stories.tsx deleted file mode 100644 index b32a12171a3af..0000000000000 --- a/packages/react-components/react-dialog/src/stories/DialogTitle/index.stories.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { DialogTitle } from '@fluentui/react-dialog'; - -export { Default } from './DialogTitleDefault.stories'; -export { CustomAction } from './DialogTitleCustomAction.stories'; -export { NoAction } from './DialogTitleNoAction.stories'; - -export default { - title: 'Preview Components/Dialog/DialogTitle', - component: DialogTitle, -};