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(core): fix getClosestPosition error when component nesting #285

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bcguan2008
Copy link

@bcguan2008 bcguan2008 commented Apr 23, 2022

问题

当组件嵌套了多个组件时,会发生 closestPosition 计算不对的问题

拿Card 举例,在 behavior 里设置了 Card 不能 append 到 Card

image

录制了一个 gif 图,拖拽滑动到子组件时光标位置计算不对。 拖拽到 input, textArea 和 password 分别发生了多次光标跳动,无法给予拖拽用户一个准确的预期

chrome-capture-2022-3-9

原因

getClosestPosition 方法做了 closestNode 的重计算(主要是 onMove 事件在方法外会修改 closestNode,所以重计算 closestNode 没有问题 ),但没有进行 isAfter 的重计算。

修复后效果
chrome-capture-2022-3-23

  • Ensure the pull request title and commit message follow the Commit Specific in English.
  • Fork the repo and create your branch from main.
  • If you've added code that should be tested, add tests!
  • If you've changed APIs, update the documentation.
  • Ensure the test suite passes (npm test).
  • Make sure your code lints (npm run lint) - we've done our best to make sure these rules match our internal linting guidelines.

@netlify
Copy link

netlify bot commented Apr 23, 2022

Deploy Preview for designable-fusion ready!

Name Link
🔨 Latest commit 89cd014
🔍 Latest deploy log https://app.netlify.com/sites/designable-fusion/deploys/626348f881e57b000977baa6
😎 Deploy Preview https://deploy-preview-285--designable-fusion.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Apr 23, 2022

Deploy Preview for designable-antd ready!

Name Link
🔨 Latest commit 89cd014
🔍 Latest deploy log https://app.netlify.com/sites/designable-antd/deploys/626348f8343e8b00081905e5
😎 Deploy Preview https://deploy-preview-285--designable-antd.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@janryWang
Copy link
Collaborator

现在main分支的最新版还存在这个问题吗

@bcguan2008
Copy link
Author

现在main分支的最新版还存在这个问题吗

有的, 比较容易复现(按问题描述里的配置方式修改 formily/antd/src/components/Card/preview.tsx)

@bcguan2008
Copy link
Author

这个 check 报错信息好像 main 上就有

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