Skip to content

Commit

Permalink
[DatePicker] Fix autoOk functionality & onTouchTapDay nomenclature
Browse files Browse the repository at this point in the history
  • Loading branch information
tintin1343 committed May 4, 2016
1 parent 4bc7aa2 commit dcb9ded
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/DatePicker/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class Calendar extends Component {
key={this.state.displayDate.toDateString()}
minDate={this.props.minDate}
maxDate={this.props.maxDate}
onDayTouchTap={this.handleTouchTapDay}
onTouchTapDay={this.handleTouchTapDay}
ref="calendar"
selectedDate={this.state.selectedDate}
shouldDisableDate={this.props.shouldDisableDate}
Expand All @@ -367,8 +367,9 @@ class Calendar extends Component {
{this.yearSelector()}
</div>
}
{this.props.showActionButtons &&
{this.props.cancelLabel && this.props.okLabel &&
<CalendarActionButtons
autoOk={this.props.autoOk}
cancelLabel={cancelLabel}
okLabel={okLabel}
onTouchTapCancel={onTouchTapCancel}
Expand Down
17 changes: 10 additions & 7 deletions src/DatePicker/CalendarActionButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import FlatButton from '../FlatButton';

class CalendarActionButton extends Component {
static propTypes = {
autoOk: PropTypes.bool,
cancelLabel: PropTypes.node,
okLabel: PropTypes.node,
onTouchTapCancel: PropTypes.func,
Expand Down Expand Up @@ -39,13 +40,15 @@ class CalendarActionButton extends Component {
primary={true}
style={styles.flatButtons}
/>
<FlatButton
disabled={this.refs.calendar !== undefined && this.refs.calendar.isSelectedDateDisabled()}
label={wordings ? wordings.ok : okLabel}
onTouchTap={this.props.onTouchTapOk}
primary={true}
style={styles.flatButtons}
/>
{!this.props.autoOk &&
<FlatButton
disabled={this.refs.calendar !== undefined && this.refs.calendar.isSelectedDateDisabled()}
label={wordings ? wordings.ok : okLabel}
onTouchTap={this.props.onTouchTapOk}
primary={true}
style={styles.flatButtons}
/>
}
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/DatePicker/CalendarMonth.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CalendarMonth extends Component {
firstDayOfWeek: PropTypes.number,
maxDate: PropTypes.object,
minDate: PropTypes.object,
onDayTouchTap: PropTypes.func,
onTouchTapDay: PropTypes.func,
selectedDate: PropTypes.object.isRequired,
shouldDisableDate: PropTypes.func,
};
Expand All @@ -19,7 +19,7 @@ class CalendarMonth extends Component {
}

handleTouchTapDay = (event, date) => {
if (this.props.onDayTouchTap) this.props.onDayTouchTap(event, date);
if (this.props.onTouchTapDay) this.props.onTouchTapDay(event, date);
};

shouldDisableDate(day) {
Expand Down
2 changes: 0 additions & 2 deletions src/DatePicker/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,10 @@ class DatePicker extends Component {

static defaultProps = {
autoOk: false,
cancelLabel: 'Cancel',
container: 'dialog',
disabled: false,
disableYearSelection: false,
firstDayOfWeek: 1,
okLabel: 'OK',
style: {},
};

Expand Down
2 changes: 1 addition & 1 deletion src/DatePicker/DatePickerDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class DatePickerDialog extends Component {

render() {
const {
// autoOk, FIXME: autoOk not working
DateTimeFormat,
cancelLabel,
container,
Expand Down Expand Up @@ -144,6 +143,7 @@ class DatePickerDialog extends Component {
onKeyUp={this.handleWindowKeyUp}
/>
<Calendar
autoOk={this.props.autoOk}
DateTimeFormat={DateTimeFormat}
cancelLabel={cancelLabel}
disableYearSelection={disableYearSelection}
Expand Down

0 comments on commit dcb9ded

Please sign in to comment.