Skip to content

Commit

Permalink
Add cancel callback for exiting without saving
Browse files Browse the repository at this point in the history
  • Loading branch information
frontsideair committed Apr 26, 2018
1 parent 748ed89 commit c16ed62
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/SaveTheDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Props = {
isOpen: boolean,
open: () => void,
close: () => void,
cancel: () => void,
selectedDate: Date | null,
onSelect: Date => void,
viewportDate: Date | null,
Expand Down Expand Up @@ -73,6 +74,10 @@ class SaveTheDate extends Component<Props, State> {
}
};

cancel = () => {
this.setState({ editing: null });
};

handleInput = (e: SyntheticInputEvent<*>) => {
if (this.state.editing) {
const date = this.parse(e.target.value);
Expand Down Expand Up @@ -129,6 +134,7 @@ class SaveTheDate extends Component<Props, State> {
isOpen: Boolean(editing),
open: this.open,
close: this.close,
cancel: this.cancel,
selectedDate: editing && editing.calendarValue,
onSelect: this.onSelect,
viewportDate: editing && editing.viewportDate,
Expand Down

0 comments on commit c16ed62

Please sign in to comment.