diff --git a/resources/js/components/fieldtypes/DateFieldtype.vue b/resources/js/components/fieldtypes/DateFieldtype.vue index d436bd50347..aa6e05dc6c7 100644 --- a/resources/js/components/fieldtypes/DateFieldtype.vue +++ b/resources/js/components/fieldtypes/DateFieldtype.vue @@ -68,7 +68,7 @@ export default { }, datePickerValue() { - if (!this.value) { + if (!this.value || this.value === 'now') { return null; } diff --git a/resources/js/tests/components/fieldtypes/DateFieldtype.test.js b/resources/js/tests/components/fieldtypes/DateFieldtype.test.js index f26de84b135..d4f8e41a4ee 100644 --- a/resources/js/tests/components/fieldtypes/DateFieldtype.test.js +++ b/resources/js/tests/components/fieldtypes/DateFieldtype.test.js @@ -29,7 +29,9 @@ const makeDateField = (props = {}) => { }, global: { provide: { - [containerContextKey]: {} + [containerContextKey]: { + withoutDirtying: (callback) => callback(), + } }, mocks: { $config: { @@ -74,3 +76,9 @@ test.each([ expect(dateField.vm.datePickerValue.toString()).toBe(expectedDate); }); + +test('datePickerValue returns null when value is "now"', () => { + const dateField = makeDateField({ value: 'now' }); + + expect(dateField.vm.datePickerValue).toBe(null); +});