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

Make "required" for Date fields work #1747

Merged
merged 1 commit into from
Aug 22, 2020
Merged
Changes from all commits
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
11 changes: 10 additions & 1 deletion assets/js/app/editor/Components/Date.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<script>
import value from '../mixins/value';
import flatPickr from 'vue-flatpickr-component';
import $ from 'jquery';

export default {
name: 'EditorDate',
Expand Down Expand Up @@ -120,6 +121,14 @@ export default {
}
},

mounted() {},
mounted() {
// Standard HTML validation doesn't work for fields that are 'readonly'. We
// this hack makes the field "editable" but have it lose focus if focused.
// @see https://github.com/flatpickr/flatpickr/issues/892
$('#datetimepicker').on('focus', ({ currentTarget }) =>
$(currentTarget).blur(),
);
$('#datetimepicker').prop('readonly', false);
},
};
</script>