1
0
Эх сурвалжийг харах

fix: fix tooltip dom not remove

DaiQiangReal 10 сар өмнө
parent
commit
809f6aa117

+ 3 - 2
packages/semi-foundation/tooltip/foundation.ts

@@ -191,7 +191,7 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
         }
     }
 
-    updateStateIfCursorOnTrigger = (trigger: HTMLElement)=>{
+    updateStateIfCursorOnTrigger = (trigger: HTMLElement) => {
         if (trigger?.matches?.(":hover")) {
             const eventNames = this._adapter.getEventName();
             const triggerEventSet = this.getState("triggerEventSet");
@@ -379,7 +379,8 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
 
     _togglePortalVisible(isVisible: boolean) {
         const nowVisible = this.getState('visible');
-        if (nowVisible !== isVisible) {
+        const isInsert = this.getState("isInsert");
+        if (nowVisible !== isVisible || isInsert !== isVisible) {
             this._adapter.togglePortalVisible(isVisible, () => {
                 if (isVisible) {
                     this._adapter.setInitialFocus();

+ 7 - 1
packages/semi-ui/tooltip/index.tsx

@@ -250,8 +250,14 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
                     },
                     () => {
                         setTimeout(() => {
+                            this.setState((oldState) => {
+                                if ( oldState.transitionState === 'enter' ) {
+                                    this.eventManager.emit('portalInserted');
+                                }
+                                return {};
+                            });
                             // waiting child component mounted
-                            this.eventManager.emit('portalInserted');
+
                         }, 0);
                     }
                 );