Skip to content

Commit

Permalink
Merge pull request #1747 from bolt/fix/required-for-date-fields
Browse files Browse the repository at this point in the history
Make "required" for Date fields work
  • Loading branch information
bobdenotter authored Aug 22, 2020
2 parents d35e4d2 + bf535c9 commit c46fabb
Showing 1 changed file with 10 additions and 1 deletion.
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>

0 comments on commit c46fabb

Please sign in to comment.