From 6acb8145fce6444cda64f05b7f2408f61d8d4332 Mon Sep 17 00:00:00 2001 From: Mozafar Haider Date: Mon, 21 Oct 2024 08:42:21 +0100 Subject: [PATCH] fix(calendar-input): trigger onFocus if passed --- components/calendar/package.json | 2 +- components/calendar/src/calendar-input/calendar-input.js | 1 + .../calendar/src/stories/calendar-input.prod.stories.js | 3 +++ yarn.lock | 8 ++++---- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/calendar/package.json b/components/calendar/package.json index d37428321..357d5fb29 100644 --- a/components/calendar/package.json +++ b/components/calendar/package.json @@ -38,7 +38,7 @@ "@dhis2-ui/input": "10.0.0-alpha.4", "@dhis2-ui/layer": "10.0.0-alpha.4", "@dhis2-ui/popper": "10.0.0-alpha.4", - "@dhis2/multi-calendar-dates": "2.0.0-alpha.2", + "@dhis2/multi-calendar-dates": "2.0.0-alpha.5", "@dhis2/prop-types": "^3.1.2", "@dhis2/ui-constants": "10.0.0-alpha.4", "@dhis2/ui-icons": "10.0.0-alpha.4", diff --git a/components/calendar/src/calendar-input/calendar-input.js b/components/calendar/src/calendar-input/calendar-input.js index 715050f25..4aebe9865 100644 --- a/components/calendar/src/calendar-input/calendar-input.js +++ b/components/calendar/src/calendar-input/calendar-input.js @@ -106,6 +106,7 @@ export const CalendarInput = ({ const onFocus = () => { setOpen(true) + rest?.onFocus?.() } const languageDirection = useResolvedDirection(dir, locale) diff --git a/components/calendar/src/stories/calendar-input.prod.stories.js b/components/calendar/src/stories/calendar-input.prod.stories.js index 92a68e77a..8ba396a2d 100644 --- a/components/calendar/src/stories/calendar-input.prod.stories.js +++ b/components/calendar/src/stories/calendar-input.prod.stories.js @@ -131,6 +131,9 @@ export function CalendarWithEditiableInput() { const date = selectedDate?.calendarDateString setDate(date) }} + onFocus={() => { + console.log('focused') + }} width="400px" minDate="2020-07-01" maxDate="2020-07-09" diff --git a/yarn.lock b/yarn.lock index 421666367..8766940ed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2707,10 +2707,10 @@ i18next "^10.3" moment "^2.24.0" -"@dhis2/multi-calendar-dates@2.0.0-alpha.3": - version "2.0.0-alpha.3" - resolved "https://registry.yarnpkg.com/@dhis2/multi-calendar-dates/-/multi-calendar-dates-2.0.0-alpha.3.tgz#37bab8ccba25c1b060c85a3d6fa3f2f0e71e26ac" - integrity sha512-og8OryjLzPmEtDR4T53R1sQ3ae8VzMU6aWLz9Rx22UM140tzGeNh9+CFhgYXnrokEqFQRs3Qyt3eLqgDOmAatw== +"@dhis2/multi-calendar-dates@2.0.0-alpha.5": + version "2.0.0-alpha.5" + resolved "https://registry.yarnpkg.com/@dhis2/multi-calendar-dates/-/multi-calendar-dates-2.0.0-alpha.5.tgz#5c7a8666a090660bb341d05c64b3464a087d58c0" + integrity sha512-ylOEMk1Va3GS+HSIRDp+f03XZ4f1RJf3j3UFmpNMMVyYjzSw2j+m/wfD+kqtpZlM3GuIwu80rFreHTR5IMrasA== dependencies: "@dhis2/d2-i18n" "^1.1.3" "@js-temporal/polyfill" "0.4.3"