| Tech | Version |
|---------------------|---------|
| material-ui-pickers | 1.0.0 RC3 |
| material-ui | 1.0.0-beta.33 |
| React | 16.2.0 |
| Browser | Version 65.0.3325.162 (Official Build) (64-bit) |
| Platform | |
Just wrap your DatePicker component into a FormControl. See live example at the end of this ticket.
import React from 'react';
import { DatePicker } from 'material-ui-pickers';
import { FormControl } from 'material-ui/Form';
class App extends React.Component {
state = { date: Date.now() };
handleDateChange = (date) => {
this.setState({ date });
};
render() {
return (
<FormControl>
<DatePicker
format="DD/MM/YYYY"
keyboard
autoOk
clearable
value={this.state.date}
onChange={this.handleDateChange}
animateYearScrolling={false}
/>
</FormControl>
)
}
}
export default App;
Normal date picking behavior
At least two weird things happen when you try picking a date:
https://codesandbox.io/s/l32rnjqn6l
This weird behavior does not happen when you use the keyboard.
I investigated a little bit and it looks like the handleClick event is not even dispatched when you click on a day. Another weird thing is that any click, including in the JS console, will make the picker go back to the current month.
Some more research:
FormControl's margin setting, no change.onClick event.DO NOT wrap pickers in the FormControl. Material-ui-pickers renders TextField
It's important to understand that the text field is a simple abstraction on top of the following components:
Most helpful comment
DO NOT wrap pickers in the FormControl. Material-ui-pickers renders TextField
It's important to understand that the text field is a simple abstraction on top of the following components: