From d2fc2d2bca34a25d83d42e6963505544cbf2ff50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Fri, 18 Feb 2022 11:00:08 +0300 Subject: [PATCH] Fixed #2186 - Calendar input value added blur event --- api-generator/components/calendar.js | 9 +++++++-- src/components/calendar/Calendar.d.ts | 15 +++++++++++++-- src/components/calendar/Calendar.vue | 4 ++-- src/views/calendar/CalendarDoc.vue | 4 +++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/api-generator/components/calendar.js b/api-generator/components/calendar.js index 08ba5a366..fd172605d 100644 --- a/api-generator/components/calendar.js +++ b/api-generator/components/calendar.js @@ -349,9 +349,14 @@ const CalendarEvents = [ description: "Callback to invoke on blur of input field.", arguments: [ { - name: "event", + name: "event.originalEvent", type: "object", - description: "Blur event" + description: "Browser event" + }, + { + name: "event.value", + type: "string", + description: "Input value" } ] }, diff --git a/src/components/calendar/Calendar.d.ts b/src/components/calendar/Calendar.d.ts index e246a69e6..1de1ca281 100755 --- a/src/components/calendar/Calendar.d.ts +++ b/src/components/calendar/Calendar.d.ts @@ -44,6 +44,17 @@ export interface CalendarYearChangeEvent { year: number; } +export interface CalendarBlurEvent { + /** + * Browser event + */ + originalEvent: Event; + /** + * Input value + */ + value: string; +} + export interface CalendarProps { /** * Value of the component. @@ -321,9 +332,9 @@ export declare type CalendarEmits = { 'focus': (event: Event) => void; /** * Callback to invoke on blur of input field. - * @param {Event} event - Blur event + * @param {CalendarBlurEvent} event - Blur event */ - 'blur': (event: Event) => void; + 'blur': (event: CalendarBlurEvent) => void; } declare class Calendar extends ClassComponent { } diff --git a/src/components/calendar/Calendar.vue b/src/components/calendar/Calendar.vue index 3733d39d4..a1200dd60 100755 --- a/src/components/calendar/Calendar.vue +++ b/src/components/calendar/Calendar.vue @@ -2182,10 +2182,10 @@ export default { this.$emit('focus', event); }, onBlur(event) { + this.$emit('blur', {originalEvent: event, value: this.input.value}); + this.focused = false; this.input.value = this.formatValue(this.modelValue); - - this.$emit('blur', event); }, onKeyDown() { if (event.keyCode === 40 && this.overlay) { diff --git a/src/views/calendar/CalendarDoc.vue b/src/views/calendar/CalendarDoc.vue index 6f2894555..50884edcc 100755 --- a/src/views/calendar/CalendarDoc.vue +++ b/src/views/calendar/CalendarDoc.vue @@ -508,7 +508,9 @@ export default { blur - event: Blur event + event.originalEvent: Blur event
+ event.value: Input value + Callback to invoke on blur of input field.