Skip to content

Commit 5e98ea3

Browse files
bherilaeddywashere
authored andcommitted
feat(Modal): Make toggle prop optional (#325)
* Make toggle prop optional on Modal re #323 * Check toggle prop for null
1 parent 25fdb77 commit 5e98ea3

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/Modal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
const propTypes = {
1515
isOpen: PropTypes.bool,
1616
size: PropTypes.string,
17-
toggle: PropTypes.func.isRequired,
17+
toggle: PropTypes.func,
1818
keyboard: PropTypes.bool,
1919
backdrop: PropTypes.oneOfType([
2020
PropTypes.bool,
@@ -90,7 +90,7 @@ class Modal extends React.Component {
9090
}
9191

9292
handleEscape(e) {
93-
if (this.props.keyboard && e.keyCode === 27) {
93+
if (this.props.keyboard && e.keyCode === 27 && this.props.toggle) {
9494
this.props.toggle();
9595
}
9696
}
@@ -100,7 +100,7 @@ class Modal extends React.Component {
100100

101101
const container = this._dialog;
102102

103-
if (e.target && !container.contains(e.target)) {
103+
if (e.target && !container.contains(e.target) && this.props.toggle) {
104104
this.props.toggle();
105105
}
106106
}

0 commit comments

Comments
 (0)