Skip to content

Commit

Permalink
DatePicker - surfaced the disable escape dismiss of dialogs (issue #48)
Browse files Browse the repository at this point in the history
added top level disableDismissWithEscapeOnDialog property to date picker which cascades through date picker dialog to dialog so that the escape key can be disabled for dismissing the popup
  • Loading branch information
djbuckley committed Jul 3, 2017
1 parent 16bb25d commit 56009fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/DatePicker/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class DatePicker extends Component {
* Override the inline-styles of DatePickerDialog's Container element.
*/
dialogContainerStyle: PropTypes.object,
/**
* Disable the ability to use the escape key to dismiss the date picker when opened in dialog mode.
*/
disableDismissWithEscapeOnDialog: PropTypes.bool,
/**
* Disables the year selection in the date picker.
*/
Expand Down Expand Up @@ -162,6 +166,7 @@ class DatePicker extends Component {
autoOk: false,
container: 'dialog',
disabled: false,
disableDismissWithEscapeOnDialog: false,
disableYearSelection: false,
firstDayOfWeek: 1,
hideCalendarDate: false,
Expand Down Expand Up @@ -303,6 +308,7 @@ class DatePicker extends Component {
container,
defaultDate, // eslint-disable-line no-unused-vars
dialogContainerStyle,
disableDismissWithEscapeOnDialog,
disableYearSelection,
firstDayOfWeek,
formatDate: formatDateProp,
Expand Down Expand Up @@ -340,6 +346,7 @@ class DatePicker extends Component {
cancelLabel={cancelLabel}
container={container}
containerStyle={dialogContainerStyle}
disableEscapeKeyForDialogs={disableDismissWithEscapeOnDialog}
disableYearSelection={disableYearSelection}
firstDayOfWeek={firstDayOfWeek}
initialDate={this.state.dialogDate}
Expand Down
5 changes: 5 additions & 0 deletions src/DatePicker/DatePickerDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class DatePickerDialog extends Component {
cancelLabel: PropTypes.node,
container: PropTypes.oneOf(['dialog', 'inline']),
containerStyle: PropTypes.object,
disableEscapeKeyForDialogs: PropTypes.bool,
disableYearSelection: PropTypes.bool,
firstDayOfWeek: PropTypes.number,
hideCalendarDate: PropTypes.bool,
Expand All @@ -37,6 +38,7 @@ class DatePickerDialog extends Component {

static defaultProps = {
DateTimeFormat: dateTimeFormat,
disableEscapeKeyForDialogs: false,
cancelLabel: 'Cancel',
container: 'dialog',
locale: 'en-US',
Expand Down Expand Up @@ -123,6 +125,7 @@ class DatePickerDialog extends Component {
cancelLabel,
container,
containerStyle,
disableEscapeKeyForDialogs,
disableYearSelection,
initialDate,
firstDayOfWeek,
Expand Down Expand Up @@ -162,6 +165,7 @@ class DatePickerDialog extends Component {
const containerId = `${componentId}-${container}Container`;
const calendarId = `${componentId}-calendar`;
const eventTarget = modal ? divId : 'window';
const escOverride = modal ? disableEscapeKeyForDialogs : null

return (
<div ref="root" id={divId} {...other}>
Expand All @@ -174,6 +178,7 @@ class DatePickerDialog extends Component {
repositionOnUpdate={true}
open={open}
onRequestClose={this.handleRequestClose}
overrideModalEscKey={escOverride}
style={Object.assign(styles.dialogBodyContent, containerStyle)}
id={containerId}
modal={modal}
Expand Down

0 comments on commit 56009fd

Please sign in to comment.