diff --git a/change/@fluentui-react-popover-cd0f51c6-92c0-4de4-917e-df1a53233d3b.json b/change/@fluentui-react-popover-cd0f51c6-92c0-4de4-917e-df1a53233d3b.json new file mode 100644 index 0000000000000..f7a024ecc90bd --- /dev/null +++ b/change/@fluentui-react-popover-cd0f51c6-92c0-4de4-917e-df1a53233d3b.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix: preventDefault when closing the popover surface to avoid closing parent dialogs.", + "packageName": "@fluentui/react-popover", + "email": "esteban.230@hotmail.com", + "dependentChangeType": "patch" +} diff --git a/packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts b/packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts index 0ad5860660b3f..425f6fec93691 100644 --- a/packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts +++ b/packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts @@ -78,6 +78,7 @@ export const usePopoverSurface_unstable = ( // only close if the event happened inside the current popover // If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack if (e.key === 'Escape' && contentRef.current?.contains(e.target as HTMLDivElement)) { + e.preventDefault(); setOpen(e, false); }