diff --git a/common/changes/@visactor/vrender-core/fix-interactive-graphic-remove_2024-09-25-09-06.json b/common/changes/@visactor/vrender-core/fix-interactive-graphic-remove_2024-09-25-09-06.json new file mode 100644 index 000000000..31fd0cc54 --- /dev/null +++ b/common/changes/@visactor/vrender-core/fix-interactive-graphic-remove_2024-09-25-09-06.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@visactor/vrender-core", + "comment": "fix: fix issue with interactive graphic while parent was removed", + "type": "none" + } + ], + "packageName": "@visactor/vrender-core" +} \ No newline at end of file diff --git a/packages/vrender-core/src/render/contributions/render/draw-interceptor.ts b/packages/vrender-core/src/render/contributions/render/draw-interceptor.ts index 148b8f1f8..71f34908d 100644 --- a/packages/vrender-core/src/render/contributions/render/draw-interceptor.ts +++ b/packages/vrender-core/src/render/contributions/render/draw-interceptor.ts @@ -336,7 +336,17 @@ export class InteractiveDrawItemInterceptorContribution implements IDrawItemInte // 默认使用原始的图元 const baseGraphic = graphic.baseGraphic as IGraphic; // 如果主图元被删除了,那把交互图元这个也删除 - if (!baseGraphic.stage) { + // 一直往上找 + let intree = !!baseGraphic.stage; + let _g = baseGraphic.parent; + while (intree && _g) { + if ((_g as any).stage === _g) { + break; + } + intree = !!_g.stage; + _g = _g.parent; + } + if (!intree) { const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive'); if (interactiveLayer) { const shadowRoot = this.getShadowRoot(interactiveLayer);