From c093e60b671528efffe64040a93e04438439476b Mon Sep 17 00:00:00 2001 From: Tom Wheeler Date: Mon, 19 Jan 2026 03:01:27 +1300 Subject: [PATCH] fix(overlays): fixes focus issue in condition editor replace modal with Dialog, fix nested structure fix #375 --- .../OverlayEditor/ConditionEditorModal.tsx | 57 +++++--- .../OverlayEditor/OverlayEditorModal.tsx | 122 +++++++++--------- 2 files changed, 101 insertions(+), 78 deletions(-) diff --git a/src/components/OverlayEditor/ConditionEditorModal.tsx b/src/components/OverlayEditor/ConditionEditorModal.tsx index a99ff01..bddbe20 100644 --- a/src/components/OverlayEditor/ConditionEditorModal.tsx +++ b/src/components/OverlayEditor/ConditionEditorModal.tsx @@ -1,4 +1,4 @@ -import Modal from '@app/components/Common/Modal'; +import Button from '@app/components/Common/Button'; import type { DragEndEvent } from '@dnd-kit/core'; import { closestCenter, @@ -16,6 +16,7 @@ import { verticalListSortingStrategy, } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; +import { Dialog } from '@headlessui/react'; import { Bars3Icon, PlusIcon, TrashIcon } from '@heroicons/react/24/outline'; import type { ApplicationCondition, @@ -712,25 +713,45 @@ export const ConditionEditorModal: React.FC = ({ }; return ( - -
-

- {intl.formatMessage(messages.description)} -

+ + {/* Backdrop */} + ); }; diff --git a/src/components/OverlayEditor/OverlayEditorModal.tsx b/src/components/OverlayEditor/OverlayEditorModal.tsx index 73624e7..a010b33 100644 --- a/src/components/OverlayEditor/OverlayEditorModal.tsx +++ b/src/components/OverlayEditor/OverlayEditorModal.tsx @@ -529,68 +529,70 @@ export const OverlayEditorModal: React.FC = ({
+ + {/* Nested modals - INSIDE Dialog for StackProvider/FocusTrap access */} + {isPreviewSelectorOpen && ( + setIsPreviewSelectorOpen(false)} + onOk={() => setIsPreviewSelectorOpen(false)} + okText="Done" + loading={false} + backgroundClickable={false} + > +
+ {availableTemplates.length === 0 ? ( +

+ {intl.formatMessage(messages.noOtherOverlays)} +

+ ) : ( +
+ {availableTemplates.map((template) => ( + + ))} +
+ )} +
+
+ )} + + {/* Condition Editor Modal */} + {isConditionEditorOpen && ( + setIsConditionEditorOpen(false)} + initialCondition={condition} + onSave={setCondition} + /> + )} - - {/* Preview Overlay Selection Modal - outside Transition to avoid Fragment prop issues */} - {isPreviewSelectorOpen && ( - setIsPreviewSelectorOpen(false)} - onOk={() => setIsPreviewSelectorOpen(false)} - okText="Done" - loading={false} - backgroundClickable={false} - > -
- {availableTemplates.length === 0 ? ( -

- {intl.formatMessage(messages.noOtherOverlays)} -

- ) : ( -
- {availableTemplates.map((template) => ( - - ))} -
- )} -
-
- )} - - {/* Condition Editor Modal */} - {isConditionEditorOpen && ( - setIsConditionEditorOpen(false)} - initialCondition={condition} - onSave={setCondition} - /> - )} ); };