My application uses the Form.Input from Semantic UI React library to insert dates. It shows a date-picker on both Chrome and Firefox but not on Safari. I've tried to use the react-datepicker library, but it has different styling and it's difficult to align its inputs with the others from Semantic UI React's Forms. What can I do?
This is an example of Form.Input type that does not work on Safari.
<Form.Input
label='From'
type='date'
min={this.state.filters.data_inizio}
value={moment(this.state.filters.data_fine).format('YYYY-MM-DD')}
onChange={
(e) => this.setState({
...this.state,
filters: {
...this.state.filters,
data_fine: moment(e.target.value).format('YYYY-MM-DD')
}
}, this.filter)
} />
My application uses the Form.Input from Semantic UI React library to insert dates. It shows a date-picker on both Chrome and Firefox but not on Safari. I've tried to use the react-datepicker library, but it has different styling and it's difficult to align its inputs with the others from Semantic UI React's Forms. What can I do?
This is an example of Form.Input type that does not work on Safari.
<Form.Input
label='From'
type='date'
min={this.state.filters.data_inizio}
value={moment(this.state.filters.data_fine).format('YYYY-MM-DD')}
onChange={
(e) => this.setState({
...this.state,
filters: {
...this.state.filters,
data_fine: moment(e.target.value).format('YYYY-MM-DD')
}
}, this.filter)
} />
Share
Improve this question
asked Jul 28, 2018 at 16:11
Luca Di LielloLuca Di Liello
1,6432 gold badges20 silver badges36 bronze badges
2
|
4 Answers
Reset to default 10 +50Bad news.
Semantic UI React does not support the input date type.
What are you seeing in Chrome & Firefox is the default browser versions of input with type="date".
Input with type="date" is not supported in Safari.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Browser_compatibility
I tried Semantic UI React and plain side-by-side
<Container>
<Form>
<Form.Input
label='From'
type='date'
min={data_inizio}
value={moment(data_fine).format('YYYY-MM-DD')}
onChange={
(e) => this.setState({
filters: {
...filters,
data_fine: moment(e.target.value).format('YYYY-MM-DD')
}
}, this.filter)
} />
</Form>
<span><strong>Plain version</strong></span><br/>
<input type="date" />
</Container>
Full example: https://codepen.io/anon/pen/GBdoQW
First picker is same as the plain one below. The first only gets some Semantic CSS.
Try in Safari. They are just regular text inputs. :(
You can try this cool date picker called 'react-dates' made by airbnb...
Github: airbnb / react-dates (for documentation)
Official Live Demo : click here
Code sandbox demo (made by me to help you get started) : https://codesandbox.io/s/l5oo5r4pxl
Finally I found a new project that implements a universal DatePicker with the style of semantic-ui-react.
Link to the GitHub repository
I found react-dates pretty useless since I'm using yarn not npm and they only added install docs for npm users.
I recommend react-day-picker, good docs, relatively easy to set up.
https://react-day-picker.js.org/
Really stupid that the safari browser devs haven't added a default html datepicker, what a joke of a browser...
Form.Input
with the attributetype="date"
– Luca Di Liello Commented Aug 2, 2018 at 13:44