[DatePicker] Can't reset date
Closed this issue · 2 comments
MihaMarkic commented
Problem description
Using DatePicker user can't reset the date once it is set. It could be solved by allowing typing of the date (I see it is a separate request) or with a button either on input field or dialog.
Link to minimally-working code that reproduces the issue
Versions
- Material-UI: 0.16.4
- React: 15.4.1
- Browser: any
linonetwo commented
Use controlled component
<DatePicker
className={styles.date}
hintText="终止日期"
container="inline"
value={this.state.filter.toTime}
onDismiss={() => this.toTimeHandler(null, null, true)}
onChange={this.toTimeHandler}
/>
toTimeHandler = (event, date, cancel) => {
const nextState = Object.assign({}, this.state);
if (!cancel) {
nextState.filter.toTime = date;
} else {
nextState.filter.toTime = null;
}
this.setState(nextState);
};
oliviertassinari commented
Closing for #4787