From 44ecc0ef3004186d67254a31aa91399d8933e0a4 Mon Sep 17 00:00:00 2001 From: Esteban Munoz Date: Fri, 12 May 2023 07:52:47 -0700 Subject: [PATCH 1/4] fix: stop propagation when closing the popover surface to avoid closing parent dialogs. --- .../src/components/PopoverSurface/usePopoverSurface.ts | 1 + 1 file changed, 1 insertion(+) 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 0ad5860660b3f2..ac6f179729166f 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.stopPropagation(); setOpen(e, false); } From 07bbbba16bd79b8ff9a8e5374cc8af04c1089a43 Mon Sep 17 00:00:00 2001 From: Esteban Munoz Date: Fri, 12 May 2023 07:54:59 -0700 Subject: [PATCH 2/4] change file --- ...react-popover-cd0f51c6-92c0-4de4-917e-df1a53233d3b.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@fluentui-react-popover-cd0f51c6-92c0-4de4-917e-df1a53233d3b.json 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 00000000000000..e2619068a91450 --- /dev/null +++ b/change/@fluentui-react-popover-cd0f51c6-92c0-4de4-917e-df1a53233d3b.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix: stop propagation when closing the popover surface to avoid closing parent dialogs.", + "packageName": "@fluentui/react-popover", + "email": "esteban.230@hotmail.com", + "dependentChangeType": "patch" +} From 6a7d1afd0e0ef39f282920fe481e75431c1fdb25 Mon Sep 17 00:00:00 2001 From: Esteban Munoz Date: Wed, 17 May 2023 14:57:58 -0700 Subject: [PATCH 3/4] requested changes --- .../src/components/PopoverSurface/usePopoverSurface.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ac6f179729166f..425f6fec93691b 100644 --- a/packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts +++ b/packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts @@ -78,7 +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.stopPropagation(); + e.preventDefault(); setOpen(e, false); } From 1d0fb0e79fe930cbf2b98a49236a7b6a419b7b32 Mon Sep 17 00:00:00 2001 From: Esteban Munoz Date: Wed, 17 May 2023 14:59:07 -0700 Subject: [PATCH 4/4] update change file --- ...ntui-react-popover-cd0f51c6-92c0-4de4-917e-df1a53233d3b.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/change/@fluentui-react-popover-cd0f51c6-92c0-4de4-917e-df1a53233d3b.json b/change/@fluentui-react-popover-cd0f51c6-92c0-4de4-917e-df1a53233d3b.json index e2619068a91450..f7a024ecc90bd1 100644 --- a/change/@fluentui-react-popover-cd0f51c6-92c0-4de4-917e-df1a53233d3b.json +++ b/change/@fluentui-react-popover-cd0f51c6-92c0-4de4-917e-df1a53233d3b.json @@ -1,6 +1,6 @@ { "type": "patch", - "comment": "fix: stop propagation when closing the popover surface to avoid closing parent dialogs.", + "comment": "fix: preventDefault when closing the popover surface to avoid closing parent dialogs.", "packageName": "@fluentui/react-popover", "email": "esteban.230@hotmail.com", "dependentChangeType": "patch"