From aa5ed39f25b907c29320b8a05fe09ae780208b5b Mon Sep 17 00:00:00 2001 From: Vedad Burgic Date: Tue, 16 Apr 2024 22:46:26 +0200 Subject: [PATCH 1/3] Update Datepicker onSelectedDateChanged signature to include isClearAction parameter --- packages/ui/src/components/Datepicker/Datepicker.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/ui/src/components/Datepicker/Datepicker.tsx b/packages/ui/src/components/Datepicker/Datepicker.tsx index 5600385f7..0cf4982a4 100644 --- a/packages/ui/src/components/Datepicker/Datepicker.tsx +++ b/packages/ui/src/components/Datepicker/Datepicker.tsx @@ -96,7 +96,7 @@ export interface DatepickerProps extends Omit { language?: string; weekStart?: WeekStart; theme?: DeepPartial; - onSelectedDateChanged?: (date: Date) => void; + onSelectedDateChanged?: (date: Date, isClearAction: boolean) => void; } const DatepickerRender: ForwardRefRenderFunction = ( @@ -137,11 +137,11 @@ const DatepickerRender: ForwardRefRenderFunction const datepickerRef = useRef(null); // Triggers when user select the date - const changeSelectedDate = (date: Date, useAutohide: boolean) => { + const changeSelectedDate = (date: Date, useAutohide: boolean, isClearAction?: boolean) => { setSelectedDate(date); if (onSelectedDateChanged) { - onSelectedDateChanged(date); + onSelectedDateChanged(date, isClearAction ?? false); } if (autoHide && view === Views.Days && useAutohide == true && !inline) { @@ -150,7 +150,7 @@ const DatepickerRender: ForwardRefRenderFunction }; const clearDate = () => { - changeSelectedDate(defaultDate, true); + changeSelectedDate(defaultDate, true, true); if (defaultDate) { setViewDate(defaultDate); } @@ -336,7 +336,7 @@ const DatepickerRender: ForwardRefRenderFunction type="button" className={twMerge(theme.popup.footer.button.base, theme.popup.footer.button.clear)} onClick={() => { - changeSelectedDate(defaultDate, true); + changeSelectedDate(defaultDate, true, true); if (defaultDate) { setViewDate(defaultDate); } From e182bcbcd77a51dc97e039eefc69a84842874bed Mon Sep 17 00:00:00 2001 From: Vedad Burgic Date: Wed, 17 Apr 2024 21:40:04 +0200 Subject: [PATCH 2/3] changeset generated --- .changeset/silent-cougars-serve.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/silent-cougars-serve.md diff --git a/.changeset/silent-cougars-serve.md b/.changeset/silent-cougars-serve.md new file mode 100644 index 000000000..c2e1aa884 --- /dev/null +++ b/.changeset/silent-cougars-serve.md @@ -0,0 +1,5 @@ +--- +"flowbite-react": patch +--- + +isClearAction added to onSelectedDateChanged in order to have context which can be used in various scenarios when we need to clear date. From d8e7cfe63bf4723a91a1c1d790855a220f806b03 Mon Sep 17 00:00:00 2001 From: Vedad Burgic Date: Sat, 4 May 2024 00:12:41 +0200 Subject: [PATCH 3/3] Update .changeset/silent-cougars-serve.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .changeset/silent-cougars-serve.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/silent-cougars-serve.md b/.changeset/silent-cougars-serve.md index c2e1aa884..db6da7480 100644 --- a/.changeset/silent-cougars-serve.md +++ b/.changeset/silent-cougars-serve.md @@ -2,4 +2,4 @@ "flowbite-react": patch --- -isClearAction added to onSelectedDateChanged in order to have context which can be used in various scenarios when we need to clear date. +Added isClearAction to onSelectedDateChanged to provide context for clear actions.