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: hide indicator outside the droppable area (#477) #478

Merged
merged 2 commits into from
Aug 28, 2021
Merged

fix: hide indicator outside the droppable area (#477) #478

merged 2 commits into from
Aug 28, 2021

Conversation

curly210102
Copy link
Contributor

@curly210102 curly210102 commented Aug 1, 2021

Resolves ant-design/ant-design#31555, resolves #477

@vercel
Copy link

vercel bot commented Aug 1, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/react-component/tree/4svGaubrM3WKbzJ1BzCETaC3WEYN
✅ Preview: https://tree-git-fork-curly210102-fix-bug-react-component.vercel.app

@codecov
Copy link

codecov bot commented Aug 2, 2021

Codecov Report

Merging #478 (5750833) into master (d2da30c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #478   +/-   ##
=======================================
  Coverage   99.74%   99.75%           
=======================================
  Files          11       11           
  Lines        1194     1203    +9     
  Branches      354      349    -5     
=======================================
+ Hits         1191     1200    +9     
  Misses          3        3           
Impacted Files Coverage Δ
src/Tree.tsx 99.55% <100.00%> (+<0.01%) ⬆️
src/util.tsx 99.26% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d2da30c...5750833. Read the comment docs.

@afc163 afc163 requested a review from 07akioni August 20, 2021 09:58
src/Tree.tsx Outdated
@@ -22,7 +22,7 @@ import {
calcDropPosition,
arrAdd,
arrDel,
posToArr,
posToArr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
posToArr
posToArr,

src/Tree.tsx Outdated
@@ -278,6 +278,8 @@ class Tree extends React.Component<TreeProps, TreeState> {

dragNode: NodeInstance;

dragEnterDroppableNodeKey = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currentMouseOverDroppableNodeKey

@curly210102
Copy link
Contributor Author

@07akioni find a new problem with this solution, drag enter/leave event fired when hovering children element. Refer to https://stackoverflow.com/questions/7110353/html5-dragleave-fired-when-hovering-a-child-element, I add a dragenter counter to check whether the mouse leave the draggable element.

@07akioni
Copy link
Contributor

07akioni commented Aug 25, 2021

, drag enter/leave event fired when hovering children element. R

Why not checking currentTarget?

@curly210102
Copy link
Contributor Author

Checking event.currentTarget === event.target? As the cursor switches between the internal blank area and the child element, event.target will return the draggable element node multiple times(Codepen Demo). Thus, It cannot used to check the cursor has left.

@07akioni
Copy link
Contributor

Codepen Demo

Nice demo.

How about

onDragLeave:
if (e.currentTarget.contains(e.relatedTarget)) {
  do nothing
} else {
  mark leave
}
onDragEnter:
if (e.currentTarget === e.target) {
  mark enter
}

@curly210102
Copy link
Contributor Author

e.currentTarget.contains(e.relatedTarget)

awesome! It's a better solution.

@afc163 afc163 merged commit 26038df into react-component:master Aug 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants