Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(extension): 【dynamic-group】DynamicGroup 使用 moveNode 进行移动时子节点没有跟随移动 #2007

Merged
merged 4 commits into from
Dec 12, 2024

Conversation

boyongjiong
Copy link
Collaborator

#1858 中,分组内节点跟随移动的逻辑被放在了 node:mousemove 事件监听中,导致只有拖拽才会触发该逻辑。对分组使用 Api 如 moveNode 时,不会触发这个事件,子节点不跟随。
现将跟随移到逻辑改到 getMoveDistance 中,拖拽和使用方法进行移动时均会执行该方法。

同时,selection-select 插件中有问题,在选择到分组节点时,会将子节点也选中,导致在做了上面的修改后,子节点会移动 n 次。
selection-select 的代码里有对分组情况的处理:

        // 如果节点属于分组,则不选中节点,此处兼容旧版 Group 插件
        if (!group || !group.getNodeGroup(element.id)) {
          this.lf.selectElementById(element.id, true)
        }
        // 如果节点属于动态分组,则不不选中节点
        if (!dynamicGroup || !dynamicGroup.getGroupByNodeId(element.id)) {
          this.lf.selectElementById(element.id, true)
        }

这样的判断在单独使用分组插件时,会有另一个 if 触发,选中节点。现在修复了该逻辑,不会影响到分组的移动

效果:
chrome-capture-2024-11-15

这样处理后也能修复 #1949 ,这种场景下,鼠标没有移动,所以不触发事件
效果:
chrome-capture-2024-11-15 (1)

wzw and others added 4 commits December 12, 2024 14:50
之前的修改中,跟随移动的逻辑被放在了 node:mousemove 事件监听中,导致只有拖拽才会触发,现改到 getMoveDistance 中,拖拽和使用方法进行移动均会执行
DynamicGroup 的子元素跟随移动逻辑中,获取了所有子元素,导致多次触发移动逻辑
…移动逻辑重复

之前的框选组件中,不选中分组节点的 if 逻辑有问题,在使用单个分组插件时,if (!group) 这样的判断会一直触发,导致会选中所有节点
Copy link

changeset-bot bot commented Dec 12, 2024

⚠️ No Changeset found

Latest commit: 2830f78

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@DymoneLewis DymoneLewis merged commit 8800b94 into master Dec 12, 2024
1 check passed
@boyongjiong boyongjiong deleted the fix/group-move-by-api branch December 12, 2024 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants