Conversation
Member
afc163
reviewed
Sep 19, 2018
| const target = event.target; | ||
| const root = findDOMNode(this); | ||
| const popupNode = this.getPopupDomNode(); | ||
| if (!contains(root, target) && !contains(popupNode, target)) { |
Member
|
多级嵌套能覆盖到么,Trigger Trigger Trigger 的情况。 |
Member
Author
Member
Author
对于 click 的应该都 cover 到了 |
afc163
approved these changes
Sep 19, 2018
afc163
reviewed
Sep 19, 2018
| onPopupMouseDown = (...args) => { | ||
| const { rcTrigger = {} } = this.context; | ||
| this.hasPopupMouseDown = true; | ||
| setTimeout(() => { |
Member
Author
然后就再也没整理过... |
Closed
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

ref: ant-design/ant-design#9114
英文不太好描述,用中文了。
就是如果一个 Trigger 的 Popup 里面放了另一个 Trigger,这个子 Trigger 的Popup 被点击会导致父 Trigger 被关闭。
因为我们的外部点击监听是通过
addEventListener触发,因而没有走 React 的生命周期。现在增加一个 context 传递方法,当子 Trigger 的 Popup 被点击的时候,父 Trigger 的 context 方法被调用会临时锁定一下,这时通过 document 的 mouseDown 事件关闭被阻止:

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