Skip to content

Commit

Permalink
Merge pull request #345 from appfolio/feature/date-input-event-tweak
Browse files Browse the repository at this point in the history
Update DateInput.js
  • Loading branch information
gthomas-appfolio authored Dec 11, 2017
2 parents f5e6d77 + b5b96c5 commit 48fad60
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/DateInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,18 @@ export default class DateInput extends React.Component {
this.setState({ open: false });
break;
case 13: // Enter
if (this.state.open) {
// To avoid submitting the form if DateInput is contained in a form
event.preventDefault();
this.setState({ open: false });
}
break;
case 27: // Esc
event.preventDefault();
this.setState({ open: false });
if (this.state.open) {
// To avoid parent elements handling the ESC key (like modals closing)
event.stopPropagation();
this.setState({ open: false });
}
break;
case 37: // Left
if (allowArrows) this.setDate(addDays(this.getCurrentDate(), -1));
Expand Down

0 comments on commit 48fad60

Please sign in to comment.