Skip to content

Comments

fix popup of trigger in another trigger click will cause parent trigger close#98

Merged
zombieJ merged 1 commit intomasterfrom
popChain
Sep 19, 2018
Merged

fix popup of trigger in another trigger click will cause parent trigger close#98
zombieJ merged 1 commit intomasterfrom
popChain

Conversation

@zombieJ
Copy link
Member

@zombieJ zombieJ commented Sep 14, 2018

ref: ant-design/ant-design#9114

英文不太好描述,用中文了。
就是如果一个 Trigger 的 Popup 里面放了另一个 Trigger,这个子 Trigger 的Popup 被点击会导致父 Trigger 被关闭。
因为我们的外部点击监听是通过 addEventListener 触发,因而没有走 React 的生命周期。

现在增加一个 context 传递方法,当子 Trigger 的 Popup 被点击的时候,父 Trigger 的 context 方法被调用会临时锁定一下,这时通过 document 的 mouseDown 事件关闭被阻止:
kapture 2018-09-14 at 16 51 13

另: rc-trigger 里的逻辑比较多,感觉需要找个时间整理一下。

@zombieJ zombieJ requested review from afc163 and yesmeck September 14, 2018 08:53
@coveralls
Copy link

Coverage Status

Coverage increased (+1.9%) to 78.32% when pulling 1c7b703 on popChain into a619be2 on master.

@afc163
Copy link
Member

afc163 commented Sep 19, 2018

const target = event.target;
const root = findDOMNode(this);
const popupNode = this.getPopupDomNode();
if (!contains(root, target) && !contains(popupNode, target)) {
Copy link
Member

Choose a reason for hiding this comment

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

为啥这行流血了。。

Copy link
Member Author

Choose a reason for hiding this comment

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

不清楚...

@afc163
Copy link
Member

afc163 commented Sep 19, 2018

多级嵌套能覆盖到么,Trigger Trigger Trigger 的情况。

@zombieJ
Copy link
Member Author

zombieJ commented Sep 19, 2018

多层:
kapture 2018-09-19 at 12 28 38

@zombieJ
Copy link
Member Author

zombieJ commented Sep 19, 2018

@afc163:
这样是不是就不需要 getPopupContainer 来解决

对于 click 的应该都 cover 到了

@zombieJ zombieJ merged commit 5b223f4 into master Sep 19, 2018
@zombieJ zombieJ deleted the popChain branch September 19, 2018 04:58
onPopupMouseDown = (...args) => {
const { rcTrigger = {} } = this.context;
this.hasPopupMouseDown = true;
setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

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

setTimeout 记得清除。

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@zombieJ
Copy link
Member Author

zombieJ commented Nov 26, 2018

@zombieJ
另: rc-trigger 里的逻辑比较多,感觉需要找个时间整理一下。

然后就再也没整理过...

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