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` + 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();