From 4d09890d69590f0c8c32b387769a6e1e14a03c33 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 29 Apr 2024 16:51:37 -0400 Subject: [PATCH] fix(datetime): navigating months in RTL works correctly (#29421) Issue number: resolves #29198 --------- ## What is the current behavior? In https://github.com/ionic-team/ionic-framework/pull/27917 I failed to account for RTL. This caused the navigation with the arrow buttons to break because the scroll position was always < 2. ## What is the new behavior? - Datetime now checks if the component is in RTL mode when creating the scrollLeft threshold. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information --- core/src/components/datetime/datetime.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/components/datetime/datetime.tsx b/core/src/components/datetime/datetime.tsx index f6a46dd61d..b7a9c53922 100644 --- a/core/src/components/datetime/datetime.tsx +++ b/core/src/components/datetime/datetime.tsx @@ -900,7 +900,8 @@ export class Datetime implements ComponentInterface { * Check below the next line ensures that we did not * swipe and abort (i.e. we swiped but we are still on the current month). */ - const month = calendarBodyRef.scrollLeft <= 2 ? startMonth : endMonth; + const condition = isRTL(this.el) ? calendarBodyRef.scrollLeft >= -2 : calendarBodyRef.scrollLeft <= 2; + const month = condition ? startMonth : endMonth; /** * The edge of the month must be lined up with