fix(core): fix getClosestPosition error when component nesting #285
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题
当组件嵌套了多个组件时,会发生 closestPosition 计算不对的问题
拿Card 举例,在 behavior 里设置了 Card 不能 append 到 Card
录制了一个 gif 图,拖拽滑动到子组件时光标位置计算不对。 拖拽到 input, textArea 和 password 分别发生了多次光标跳动,无法给予拖拽用户一个准确的预期
原因
getClosestPosition 方法做了 closestNode 的重计算(主要是 onMove 事件在方法外会修改 closestNode,所以重计算 closestNode 没有问题 ),但没有进行 isAfter 的重计算。
修复后效果
main
.npm test
).npm run lint
) - we've done our best to make sure these rules match our internal linting guidelines.