File tree Expand file tree Collapse file tree 1 file changed +20
-16
lines changed
packages/coreui-react/src/components/popover Expand file tree Collapse file tree 1 file changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,26 @@ export const CPopover = forwardRef<HTMLDivElement, CPopoverProps>(
136
136
useEffect ( ( ) => {
137
137
if ( _visible ) {
138
138
setMounted ( true )
139
+ }
139
140
141
+ return ( ) => {
142
+ if ( popoverRef . current ) {
143
+ popoverRef . current . classList . remove ( 'show' )
144
+ onHide && onHide ( )
145
+ executeAfterTransition ( ( ) => {
146
+ if ( popoverRef . current ) {
147
+ popoverRef . current . style . display = 'none'
148
+ }
149
+
150
+ destroyPopper ( )
151
+ setMounted ( false )
152
+ } , popoverRef . current )
153
+ }
154
+ }
155
+ } , [ _visible ] )
156
+ useEffect ( ( ) => {
157
+ if ( mounted ) {
158
+ // On the render after `setMounted(true)`, the popoverRef will be populated
140
159
if ( popoverRef . current ) {
141
160
popoverRef . current . classList . remove ( 'fade' , 'show' )
142
161
destroyPopper ( )
@@ -155,22 +174,7 @@ export const CPopover = forwardRef<HTMLDivElement, CPopoverProps>(
155
174
}
156
175
} , _delay . show )
157
176
}
158
-
159
- return ( ) => {
160
- if ( popoverRef . current ) {
161
- popoverRef . current . classList . remove ( 'show' )
162
- onHide && onHide ( )
163
- executeAfterTransition ( ( ) => {
164
- if ( popoverRef . current ) {
165
- popoverRef . current . style . display = 'none'
166
- }
167
-
168
- destroyPopper ( )
169
- setMounted ( false )
170
- } , popoverRef . current )
171
- }
172
- }
173
- } , [ _visible ] )
177
+ } , [ mounted ] )
174
178
175
179
return (
176
180
< >
You can’t perform that action at this time.
0 commit comments