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

Fixed #117: Added functionality to ignore the closing of popup when the target has a special class via prop:ignoreVisibilityChangeClassName #118

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ ReactDOM.render((
<td></td>
<td>Let popup div stretch with trigger element. enums of 'width', 'minWidth', 'height', 'minHeight'. (You can also mixed with 'height minWidth')</td>
</tr>
<tr>
<td>ignoreVisibilityChangeClassName</td>
<td>string</td>
<td></td>
<td>Ignore the pop visibility change to false when the target has the `ignoreVisibilityChangeClassName`</td>
</tr>
</tbody>
</table>

Expand Down
12 changes: 11 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -105,6 +106,7 @@ export default class Trigger extends React.Component {
action: [],
showAction: [],
hideAction: [],
ignoreVisibilityChangeClassName: '',
};

constructor(props) {
Expand Down Expand Up @@ -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();
Expand Down