diff --git a/change/@fluentui-react-tabster-5065c018-0a25-4a76-9359-7f114ddf23e8.json b/change/@fluentui-react-tabster-5065c018-0a25-4a76-9359-7f114ddf23e8.json new file mode 100644 index 00000000000000..8b927cc436a17f --- /dev/null +++ b/change/@fluentui-react-tabster-5065c018-0a25-4a76-9359-7f114ddf23e8.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "feat: add modalizer id to `useModalAttributes` option", + "packageName": "@fluentui/react-tabster", + "email": "yuanboxue@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/react-components/react-tabster/etc/react-tabster.api.md b/packages/react-components/react-tabster/etc/react-tabster.api.md index a492d34543bc41..a5bb20d7d6d516 100644 --- a/packages/react-components/react-tabster/etc/react-tabster.api.md +++ b/packages/react-components/react-tabster/etc/react-tabster.api.md @@ -90,6 +90,7 @@ export const useModalAttributes: (options?: UseModalAttributesOptions) => { // @public (undocumented) export interface UseModalAttributesOptions { alwaysFocusable?: boolean; + id?: string; legacyTrapFocus?: boolean; trapFocus?: boolean; } diff --git a/packages/react-components/react-tabster/src/hooks/useModalAttributes.ts b/packages/react-components/react-tabster/src/hooks/useModalAttributes.ts index f3e58dcc14f4f1..56097ee95dc540 100644 --- a/packages/react-components/react-tabster/src/hooks/useModalAttributes.ts +++ b/packages/react-components/react-tabster/src/hooks/useModalAttributes.ts @@ -24,6 +24,11 @@ export interface UseModalAttributesOptions { * Always reachabled in Tab order */ alwaysFocusable?: boolean; + + /** + * Id to use for the modalizer. An id will be generated if not provided. + */ + id?: string; } /** @@ -44,7 +49,7 @@ export const useModalAttributes = ( getDeloser(tabster); } - const id = useId('modal-'); + const id = useId('modal-', options.id); const modalAttributes = useTabsterAttributes({ deloser: {}, modalizer: {