@@ -14,7 +14,7 @@ import { Layers } from "constants/Layers";
1414import { HintPlaceHolder , Modal , Section , sectionNames } from "lowcoder-design" ;
1515import { trans } from "i18n" ;
1616import { changeChildAction } from "lowcoder-core" ;
17- import { CSSProperties , useCallback , useMemo , useRef } from "react" ;
17+ import { CSSProperties , useCallback , useEffect , useMemo , useRef } from "react" ;
1818import { ResizeHandle } from "react-resizable" ;
1919import styled , { css } from "styled-components" ;
2020import { useUserViewMode } from "util/hooks" ;
@@ -118,6 +118,12 @@ let TmpModalComp = (function () {
118118 const appID = useApplicationId ( ) ;
119119 const containerRef = useRef < HTMLElement | null > ( null ) ;
120120
121+ useEffect ( ( ) => {
122+ return ( ) => {
123+ containerRef . current = null ;
124+ } ;
125+ } , [ ] ) ;
126+
121127 // Memoize body style
122128 const bodyStyle = useMemo < CSSProperties > ( ( ) => ( {
123129 padding : 0 ,
@@ -171,11 +177,9 @@ let TmpModalComp = (function () {
171177
172178 // Memoize container getter
173179 const getContainer = useCallback ( ( ) => {
174- if ( ! containerRef . current ) {
175- containerRef . current = document . querySelector ( `#${ CanvasContainerID } ` ) || document . body ;
176- }
180+ containerRef . current = document . querySelector ( `#${ CanvasContainerID } ` ) || document . body ;
177181 return containerRef . current ;
178- } , [ ] ) ;
182+ } , [ CanvasContainerID ] ) ;
179183
180184 // Memoize event handlers
181185 const handleCancel = useCallback ( ( e : React . MouseEvent ) => {
@@ -228,6 +232,7 @@ let TmpModalComp = (function () {
228232 mask = { props . showMask }
229233 className = { clsx ( `app-${ appID } ` , props . className ) }
230234 data-testid = { props . dataTestId as string }
235+ destroyOnHidden
231236 >
232237 < InnerGrid
233238 { ...props . container }
0 commit comments