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: remove onMouseDown to resolve popover close #613

Closed
wants to merge 1 commit into from

Conversation

geekrainy
Copy link

存在场景,当 Popover 内有 Modal 框,Modal 框内存在 Select 组件,为 Tag 模式,此时点击标签的 x 号会导致 Popover 被关闭。

Demo:
https://codesandbox.io/s/congfucengneiguanbi-antd4141-forked-e1bcd?file=/index.js

此 PR 允许标签的关闭按钮冒泡到 rc-trigger 的 onPopupMouseDown:
https://github.com/react-component/trigger/blob/89eefdb148ee68e4bbfe5b5b2887ceaff6b2e42c/src/index.tsx#L386

在如下判断中生效:
https://github.com/react-component/trigger/blob/89eefdb148ee68e4bbfe5b5b2887ceaff6b2e42c/src/index.tsx#L410

修复问题。

@vercel
Copy link

vercel bot commented Mar 23, 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/select/2iqhGzNDxANvWXwWTkMMgj7JPP8o
✅ Preview: https://select-git-fork-geekrainy-master-react-component.vercel.app

@geekrainy
Copy link
Author

#582

@codecov
Copy link

codecov bot commented Mar 23, 2021

Codecov Report

Merging #613 (25b26da) into master (45856a8) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 25b26da differs from pull request most recent head c7fa36f. Consider uploading reports for the commit c7fa36f to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #613      +/-   ##
==========================================
- Coverage   99.18%   99.17%   -0.01%     
==========================================
  Files          20       20              
  Lines         977      975       -2     
  Branches      327      328       +1     
==========================================
- Hits          969      967       -2     
  Misses          7        7              
  Partials        1        1              
Impacted Files Coverage Δ
src/Selector/MultipleSelector.tsx 100.00% <100.00%> (ø)
src/Selector/index.tsx 97.01% <100.00%> (+0.09%) ⬆️

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 45856a8...c7fa36f. Read the comment docs.

@geekrainy
Copy link
Author

@xrkffgg

if (event.target !== inputRef.current && !inputMouseDown) {
event.preventDefault();
}
const tagCloseMouseDown = (event.target as HTMLElement).innerText === '×';
Copy link
Member

Choose a reason for hiding this comment

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

antd 那是 svg,也有自定义的 tag

@@ -107,7 +103,6 @@ const SelectSelector: React.FC<SelectorProps> = props => {
{closable && (
<TransBtn
className={`${selectionPrefixCls}-item-remove`}
onMouseDown={onPreventMouseDown}
Copy link
Member

Choose a reason for hiding this comment

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

@zombieJ 这个之前禁鼠标 down ,是想自定义的 tag 自己去处理鼠标事件?

@zombieJ
Copy link
Member

zombieJ commented Mar 25, 2021

这个重现好邪典…………真实场景是什么样子的,能说说不?

@geekrainy
Copy link
Author

真实场景,比如表格列上面的筛选面板,里面放置一个带 Modal 框的组件,用于在 Model 框内选择数据进行过滤。当 Model 框内存在 Select 组件时,就会触发这个场景了。

@zombieJ
Copy link
Member

zombieJ commented Mar 25, 2021

点击 tag 关闭导致 popover 关闭是来自于 stopPropagation 截断导致。简单移除会导致外部监听 mouseDown 事件的逻辑全部 breaking change。需要找其他解法。

@geekrainy
Copy link
Author

最新已修复

@geekrainy geekrainy closed this Apr 25, 2021
@geekrainy
Copy link
Author

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.

3 participants