fix: 修复条件节点收起后分支连线丢失
- 在 tinyflow 条件节点收起态保留分支 handle,避免连线因 DOM 卸载消失 - 在节点折叠切换后刷新 xyflow 内部信息,确保连线锚点位置同步
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
<script lang="ts">
|
||||
import {Handle, type NodeProps, NodeToolbar, Position, useSvelteFlow} from '@xyflow/svelte';
|
||||
import {
|
||||
Handle,
|
||||
type NodeProps,
|
||||
NodeToolbar,
|
||||
Position,
|
||||
useSvelteFlow,
|
||||
useUpdateNodeInternals
|
||||
} from '@xyflow/svelte';
|
||||
import {Button, Collapse, FloatingTrigger, Input, Textarea} from '../base';
|
||||
import {type Snippet} from 'svelte';
|
||||
import {useDeleteNode} from '../utils/useDeleteNode.svelte';
|
||||
@@ -41,6 +48,7 @@
|
||||
|
||||
let activeKeys = data.expand ? ['key'] : [];
|
||||
const { updateNodeData, getNode } = useSvelteFlow();
|
||||
const updateNodeInternals = useUpdateNodeInternals();
|
||||
|
||||
const items = $derived.by(() => {
|
||||
return [{
|
||||
@@ -244,6 +252,7 @@
|
||||
<div class="tf-node-wrapper-body">
|
||||
<Collapse {items} activeKeys={activeKeys} onChange={(_,actionKeys) => {
|
||||
updateNodeData(id, {expand: actionKeys?.includes('key')})
|
||||
updateNodeInternals(id);
|
||||
onCollapse?.(actionKeys?.includes('key') ? 'key' : '')
|
||||
}} />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user