From a7914bb6745abb30b59f6b1e706b77c1808dfd34 Mon Sep 17 00:00:00 2001 From: arorayash Date: Thu, 21 Feb 2019 13:18:22 +0530 Subject: [PATCH 1/2] support: ignore visibility change on clicking specified targets --- src/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index a868b87a..d9f7656a 100644 --- a/src/index.js +++ b/src/index.js @@ -78,6 +78,7 @@ export default class Trigger extends React.Component { maskAnimation: PropTypes.string, stretch: PropTypes.string, alignPoint: PropTypes.bool, // Maybe we can support user pass position in the future + ignoreVisibilityChangeClassName: PropTypes.string, }; static contextTypes = contextTypes; @@ -105,6 +106,7 @@ export default class Trigger extends React.Component { action: [], showAction: [], hideAction: [], + ignoreVisibilityChangeClassName: '', }; constructor(props) { @@ -326,8 +328,16 @@ export default class Trigger extends React.Component { if (this.props.mask && !this.props.maskClosable) { return; } - + const { ignoreVisibilityChangeClassName } = this.props; const target = event.target; + if ( + ignoreVisibilityChangeClassName && + typeof target.className === 'string' && + target.className.split(' ').filter(className => className === ignoreVisibilityChangeClassName) + .length > 0 + ) { + return; + } const root = findDOMNode(this); if (!contains(root, target) && !this.hasPopupMouseDown) { this.close(); From 3fd4867b00d1365b92bcaa552110f7597d34791c Mon Sep 17 00:00:00 2001 From: arorayash Date: Thu, 21 Feb 2019 13:42:07 +0530 Subject: [PATCH 2/2] added docs for ignoreVisibilityChangeClassName --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index b1f83a39..f1a5925c 100644 --- a/README.md +++ b/README.md @@ -245,6 +245,12 @@ ReactDOM.render(( Let popup div stretch with trigger element. enums of 'width', 'minWidth', 'height', 'minHeight'. (You can also mixed with 'height minWidth') + + ignoreVisibilityChangeClassName + string + + Ignore the pop visibility change to false when the target has the `ignoreVisibilityChangeClassName` +