From d76a24dd9e485a2f3cc517231bbb1dab51fa1fd3 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Thu, 13 Oct 2022 15:34:28 -0500 Subject: [PATCH] fix(datetime): selecting days updates value (#26121) --- core/src/components/datetime/datetime.tsx | 94 +++++++++---------- .../datetime/test/basic/datetime.e2e.ts | 33 +++++++ .../test/prefer-wheel/datetime.e2e.ts | 76 +++++++++++++++ 3 files changed, 154 insertions(+), 49 deletions(-) diff --git a/core/src/components/datetime/datetime.tsx b/core/src/components/datetime/datetime.tsx index dc68c86a07..6420b48d68 100644 --- a/core/src/components/datetime/datetime.tsx +++ b/core/src/components/datetime/datetime.tsx @@ -561,7 +561,7 @@ export class Datetime implements ComponentInterface { * "activePartsClone" and then falling back to * today's DatetimeParts if no active date is selected. */ - private getDefaultPart = () => { + private getDefaultPart = (): DatetimeParts => { const { activePartsClone, todayParts } = this; const firstPart = Array.isArray(activePartsClone) ? activePartsClone[0] : activePartsClone; @@ -1393,7 +1393,9 @@ export class Datetime implements ComponentInterface { } private renderCombinedDatePickerColumn() { - const { activeParts, workingParts, locale, minParts, maxParts, todayParts, isDateEnabled } = this; + const { workingParts, locale, minParts, maxParts, todayParts, isDateEnabled } = this; + + const activePart = this.getDefaultPart(); /** * By default, generate a range of 3 months: @@ -1489,12 +1491,10 @@ export class Datetime implements ComponentInterface { ...findPart, }); - if (!Array.isArray(activeParts)) { - this.setActiveParts({ - ...activeParts, - ...findPart, - }); - } + this.setActiveParts({ + ...activePart, + ...findPart, + }); // We can re-attach the scroll listener after // the working parts have been updated. @@ -1583,7 +1583,9 @@ export class Datetime implements ComponentInterface { return []; } - const { activeParts, workingParts } = this; + const { workingParts } = this; + + const activePart = this.getDefaultPart(); return (