From 117b83ad57d266e135c9d8323caec6db6b74521a Mon Sep 17 00:00:00 2001 From: VachetVirginie Date: Tue, 30 Jul 2024 16:04:09 +0200 Subject: [PATCH] Improvement/date picker change delete system (#3670) --- .../__snapshots__/FormBuilder.spec.ts.snap | 3 +-- .../src/patterns/DatePicker/DatePicker.vue | 20 +++++------------ .../DatePicker/tests/DatePicker.spec.ts | 22 ------------------- 3 files changed, 6 insertions(+), 39 deletions(-) diff --git a/packages/synapse-bridge/src/form-builder/FormBuilder/tests/__snapshots__/FormBuilder.spec.ts.snap b/packages/synapse-bridge/src/form-builder/FormBuilder/tests/__snapshots__/FormBuilder.spec.ts.snap index c1fb026427..feabc763d4 100644 --- a/packages/synapse-bridge/src/form-builder/FormBuilder/tests/__snapshots__/FormBuilder.spec.ts.snap +++ b/packages/synapse-bridge/src/form-builder/FormBuilder/tests/__snapshots__/FormBuilder.spec.ts.snap @@ -268,8 +268,7 @@ exports[`FormBuilder > renders correctly 1`] = `
- -
+ Date: - inputValue:
diff --git a/packages/synapse-bridge/src/patterns/DatePicker/DatePicker.vue b/packages/synapse-bridge/src/patterns/DatePicker/DatePicker.vue index 96d48fa921..dca4280c04 100644 --- a/packages/synapse-bridge/src/patterns/DatePicker/DatePicker.vue +++ b/packages/synapse-bridge/src/patterns/DatePicker/DatePicker.vue @@ -212,9 +212,6 @@ export default defineComponent({ if (newVal) { this.lastTypeAddedDate = 'date' this.$emit('change', newVal) - if (newVal.length === 10) { - this.validate(newVal) - } if (typeof newVal === 'string' && newVal.length === 10) { this.$emit('update:model-value', this.formatDate(newVal)) } @@ -239,6 +236,7 @@ export default defineComponent({ ) if (newVal.length === 10) { this.validate(newVal) + this.inputValue = newVal } } else if ( typeof newVal === 'string' && @@ -296,6 +294,7 @@ export default defineComponent({ if (typeof this.modelValue === 'string') { const [day, month, year] = this.modelValue.split(/[-/]/) this.date = new Date(Number(year), Number(month) - 1, Number(day)) + this.inputValue = this.modelValue } }, methods: { @@ -526,18 +525,11 @@ export default defineComponent({ ? 'underlined' : 'outlined' }, - onClear() { + onClearInput() { this.date = null this.inputValue = '' this.$emit('update:model-value', null) }, - handleKeyDown(event: KeyboardEvent) { - if (event.key === 'Backspace' || event.key === 'Delete') { - this.inputValue = '' - this.date = null - this.$emit('update:model-value', null) - } - }, async handleCut(event?: ClipboardEvent) { if (event && event.clipboardData) { this.inputValue = ''; @@ -596,7 +588,7 @@ export default defineComponent({ {{ date.getDate() }}
-