Skip to content

Commit

Permalink
Dialog - changed the default behaviour for cancel (issue #48)
Browse files Browse the repository at this point in the history
The default behaviour is not for escape to cancel a dialog (see supporting documentation for this in issue #48).
Added a new property to dialog to allow for escape to be disabled, so the old functionality can be enabled if required.
  • Loading branch information
djbuckley committed Jul 3, 2017
1 parent 6cafcb8 commit 16bb25d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Dialog/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class DialogInline extends Component {
open: PropTypes.bool.isRequired,
overlayClassName: PropTypes.string,
overlayStyle: PropTypes.object,
overrideModalEscKey: PropTypes.bool,
paperClassName: PropTypes.string,
paperProps: PropTypes.object,
repositionOnUpdate: PropTypes.bool,
Expand Down Expand Up @@ -272,7 +273,7 @@ class DialogInline extends Component {
}

requestClose(buttonClicked) {
if (!buttonClicked && this.props.modal) {
if (!buttonClicked && (this.props.modal && this.props.overrideModalEscKey)) {
return;
}

Expand Down Expand Up @@ -516,6 +517,10 @@ class Dialog extends Component {
* Overrides the inline-styles of the `Overlay` component that is rendered behind the `Dialog`.
*/
overlayStyle: PropTypes.object,
/**
* Overrides the use of the escape key for cancelling a modal dialog
*/
overrideModalEscKey: PropTypes.bool,
/**
* The CSS class name of the `Paper` element.
*/
Expand Down Expand Up @@ -554,6 +559,7 @@ class Dialog extends Component {
autoDetectWindowHeight: true,
autoScrollBodyContent: false,
modal: false,
overrideModalEscKey: false,
repositionOnUpdate: true,
};

Expand Down

0 comments on commit 16bb25d

Please sign in to comment.