Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow typing in date widget #1247

Merged
merged 5 commits into from
Apr 14, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/components/EditorWidgets/Date/DateControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ export default class DateControl extends React.Component {

handleChange = datetime => {
const { onChange } = this.props;
if (!this.format || datetime === '') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do still need to handle the empty case here, in case the user wants to empty the field.

onChange(datetime);
} else {
// Set the date if the format is valid (moment or Date object otherwise datetime is a string).
if (moment.isMoment(datetime) || datetime instanceof Date) {
const formattedValue = moment(datetime).format(this.format);
onChange(formattedValue);
}
Expand Down