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: trigger close only when click wrap itself #218

Merged
merged 2 commits into from
Dec 19, 2020
Merged

fix: trigger close only when click wrap itself #218

merged 2 commits into from
Dec 19, 2020

Conversation

kerm1it
Copy link
Member

@kerm1it kerm1it commented Dec 16, 2020

fix ant-design/ant-design#28353
fix ant-design/ant-design#28399

ant-design/ant-design#28353 中,点击 label 中的元素,label 会连续触发两次点击事件,冒泡到父级弹窗的时候,由于父子弹窗没有包含的关系,就会触发父级的关闭事件。

ant-design/ant-design#28399 是因为在下拉框中的触发点击事件,冒泡了上来,但是下拉框和弹窗没有包含关系,也会触发关闭事件。

!contains(contentRef.current.getDOM(), e.target as HTMLElement)
这里的逻辑其实就是只要不是点击的内容就触发关闭,在弹窗中 wrap 是撑满屏幕,不点击内容就是点击 wrap 本身,刚好规避了上述两种特殊情况

@zombieJ 评估一下,有没有副作用。

@vercel
Copy link

vercel bot commented Dec 16, 2020

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/dialog/lfoqnigt9
✅ Preview: https://dialog-git-fix-28353.react-component.vercel.app

@kerm1it kerm1it requested a review from zombieJ December 16, 2020 13:13
@codecov
Copy link

codecov bot commented Dec 16, 2020

Codecov Report

Merging #218 (c0ed853) into master (586bfcb) will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #218      +/-   ##
==========================================
- Coverage   98.10%   98.08%   -0.02%     
==========================================
  Files           6        6              
  Lines         158      157       -1     
  Branches       46       46              
==========================================
- Hits          155      154       -1     
  Misses          2        2              
  Partials        1        1              
Impacted Files Coverage Δ
src/Dialog/Content/index.tsx 95.23% <ø> (-0.12%) ⬇️
src/Dialog/index.tsx 100.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 586bfcb...c0ed853. Read the comment docs.

@afc163
Copy link
Member

afc163 commented Dec 17, 2020

也看看 ant-design/ant-design#28399

@kerm1it kerm1it changed the title fix: stop root node click bubble fix: trigger close only when click wrap itself Dec 17, 2020
@kerm1it
Copy link
Member Author

kerm1it commented Dec 17, 2020

也看看 ant-design/ant-design#28399

两个是一个问题,一块儿改了

@afc163 afc163 merged commit af7fe50 into master Dec 19, 2020
@afc163 afc163 deleted the fix-28353 branch December 19, 2020 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants