From db46ee81af43312eaa33229def0ca825879f1138 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, 25 Feb 2022 16:36:21 +0300 Subject: [PATCH] Fixed #2219 - Calendar keydown event --- api-generator/components/calendar.js | 11 +++++++++++ src/components/calendar/Calendar.d.ts | 4 ++++ src/components/calendar/Calendar.vue | 4 +++- src/views/calendar/CalendarDoc.vue | 5 +++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/api-generator/components/calendar.js b/api-generator/components/calendar.js index fd172605d..d9eeb84cf 100644 --- a/api-generator/components/calendar.js +++ b/api-generator/components/calendar.js @@ -360,6 +360,17 @@ const CalendarEvents = [ } ] }, + { + name: "keydown", + description: "Callback to invoke when a key is pressed.", + arguments: [ + { + name: "event", + type: "object", + description: "Keydown event" + } + ] + } ]; const CalendarSlots = [ diff --git a/src/components/calendar/Calendar.d.ts b/src/components/calendar/Calendar.d.ts index 1de1ca281..a835ff953 100755 --- a/src/components/calendar/Calendar.d.ts +++ b/src/components/calendar/Calendar.d.ts @@ -335,6 +335,10 @@ export declare type CalendarEmits = { * @param {CalendarBlurEvent} event - Blur event */ 'blur': (event: CalendarBlurEvent) => void; + /** + * Callback to invoke when a key is pressed. + */ + 'keydown': (event: Event) => void; } declare class Calendar extends ClassComponent { } diff --git a/src/components/calendar/Calendar.vue b/src/components/calendar/Calendar.vue index d3383ac5c..a7419e09b 100755 --- a/src/components/calendar/Calendar.vue +++ b/src/components/calendar/Calendar.vue @@ -150,7 +150,7 @@ import Ripple from 'primevue/ripple'; export default { name: 'Calendar', inheritAttrs: false, - emits: ['show', 'hide', 'input', 'month-change', 'year-change', 'date-select', 'update:modelValue', 'today-click', 'clear-click', 'focus', 'blur'], + emits: ['show', 'hide', 'input', 'month-change', 'year-change', 'date-select', 'update:modelValue', 'today-click', 'clear-click', 'focus', 'blur', 'keydown'], props: { modelValue: null, selectionMode: { @@ -2157,6 +2157,8 @@ export default { //Noop break; } + + this.$emit('keydown', event); }, onInput(event) { try { diff --git a/src/views/calendar/CalendarDoc.vue b/src/views/calendar/CalendarDoc.vue index 50884edcc..6d80659b0 100755 --- a/src/views/calendar/CalendarDoc.vue +++ b/src/views/calendar/CalendarDoc.vue @@ -513,6 +513,11 @@ export default { Callback to invoke on blur of input field. + + keydown + event: Keyboard event + Callback to invoke when a key is pressed. +