@@ -14,7 +14,7 @@ import { Layers } from "constants/Layers";
14
14
import { HintPlaceHolder , Modal , Section , sectionNames } from "lowcoder-design" ;
15
15
import { trans } from "i18n" ;
16
16
import { changeChildAction } from "lowcoder-core" ;
17
- import { CSSProperties , useCallback , useMemo , useRef } from "react" ;
17
+ import { CSSProperties , useCallback , useEffect , useMemo , useRef } from "react" ;
18
18
import { ResizeHandle } from "react-resizable" ;
19
19
import styled , { css } from "styled-components" ;
20
20
import { useUserViewMode } from "util/hooks" ;
@@ -118,6 +118,12 @@ let TmpModalComp = (function () {
118
118
const appID = useApplicationId ( ) ;
119
119
const containerRef = useRef < HTMLElement | null > ( null ) ;
120
120
121
+ useEffect ( ( ) => {
122
+ return ( ) => {
123
+ containerRef . current = null ;
124
+ } ;
125
+ } , [ ] ) ;
126
+
121
127
// Memoize body style
122
128
const bodyStyle = useMemo < CSSProperties > ( ( ) => ( {
123
129
padding : 0 ,
@@ -171,11 +177,9 @@ let TmpModalComp = (function () {
171
177
172
178
// Memoize container getter
173
179
const getContainer = useCallback ( ( ) => {
174
- if ( ! containerRef . current ) {
175
- containerRef . current = document . querySelector ( `#${ CanvasContainerID } ` ) || document . body ;
176
- }
180
+ containerRef . current = document . querySelector ( `#${ CanvasContainerID } ` ) || document . body ;
177
181
return containerRef . current ;
178
- } , [ ] ) ;
182
+ } , [ CanvasContainerID ] ) ;
179
183
180
184
// Memoize event handlers
181
185
const handleCancel = useCallback ( ( e : React . MouseEvent ) => {
@@ -228,6 +232,7 @@ let TmpModalComp = (function () {
228
232
mask = { props . showMask }
229
233
className = { clsx ( `app-${ appID } ` , props . className ) }
230
234
data-testid = { props . dataTestId as string }
235
+ destroyOnHidden
231
236
>
232
237
< InnerGrid
233
238
{ ...props . container }
0 commit comments