diff --git a/gradle/changelog/nested_modal.yaml b/gradle/changelog/nested_modal.yaml new file mode 100644 index 0000000000..c95e7e30de --- /dev/null +++ b/gradle/changelog/nested_modal.yaml @@ -0,0 +1,2 @@ +- type: Fixed + description: Remove deletion of empty modalRoot node to allow a different modal to continue to exist ([#1779](https://github.com/scm-manager/scm-manager/pull/1779)) diff --git a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap index b7e41bfa8c..78f3a9a8de 100644 --- a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap +++ b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap @@ -72244,6 +72244,8 @@ exports[`Storyshots Modal|Modal Default 1`] = `null`; exports[`Storyshots Modal|Modal Long content 1`] = `null`; +exports[`Storyshots Modal|Modal Nested 1`] = `null`; + exports[`Storyshots Modal|Modal With form elements 1`] = `null`; exports[`Storyshots Modal|Modal With long tooltips 1`] = `null`; diff --git a/scm-ui/ui-components/src/modals/Modal.stories.tsx b/scm-ui/ui-components/src/modals/Modal.stories.tsx index bc760e8c47..7a3bc33020 100644 --- a/scm-ui/ui-components/src/modals/Modal.stories.tsx +++ b/scm-ui/ui-components/src/modals/Modal.stories.tsx @@ -72,7 +72,7 @@ const withFormElementsFooter = ( ); storiesOf("Modal|Modal", module) - .addDecorator(story => {story()}) + .addDecorator((story) => {story()}) .add("Default", () => (

{text}

@@ -83,6 +83,11 @@ storiesOf("Modal|Modal", module)

{text}

)) + .add("Nested", () => ( + +

{text}

+
+ )) .add("With form elements", () => ( { return ; }; + +const NestedModal: FC = ({ children }) => { + const [showOuter, setShowOuter] = useState(true); + const [showInner, setShowInner] = useState(false); + const outerBody = ( + + ); + + return ( + <> + {showOuter && ( + setShowOuter(!showOuter)} + active={showOuter} + title="Outer Hitchhiker Modal" + size="M" + /> + )} + {showInner && ( + setShowInner(!showInner)} + active={showInner} + title="Inner Hitchhiker Modal" + /> + )} + + ); +}; diff --git a/scm-ui/ui-components/src/usePortalRootElement.ts b/scm-ui/ui-components/src/usePortalRootElement.ts index 053ac0517e..1d690b31bd 100644 --- a/scm-ui/ui-components/src/usePortalRootElement.ts +++ b/scm-ui/ui-components/src/usePortalRootElement.ts @@ -44,9 +44,6 @@ const usePortalRootElement = (id: string) => { } setRootElement(element); return () => { - if (element) { - element.remove(); - } setRootElement(undefined); }; }, [id]);