From 3a64de49dbf470d470cb4516df2a5226ba751051 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Thu, 16 Feb 2023 14:41:09 -0500 Subject: [PATCH] fix(swipe-back): gesture rtl setting is reactive (#26795) resolves #26794 --- core/src/utils/gesture/swipe-back.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/utils/gesture/swipe-back.ts b/core/src/utils/gesture/swipe-back.ts index b3e0a20dd9..2a8da3abd3 100644 --- a/core/src/utils/gesture/swipe-back.ts +++ b/core/src/utils/gesture/swipe-back.ts @@ -12,7 +12,7 @@ export const createSwipeBackGesture = ( onEndHandler: (shouldComplete: boolean, step: number, dur: number) => void ): Gesture => { const win = el.ownerDocument!.defaultView!; - const rtl = isRTL(el); + let rtl = isRTL(el); /** * Determine if a gesture is near the edge @@ -39,6 +39,13 @@ export const createSwipeBackGesture = ( }; const canStart = (detail: GestureDetail) => { + /** + * The user's locale can change mid-session, + * so we need to check text direction at + * the beginning of every gesture. + */ + rtl = isRTL(el); + return isAtEdge(detail) && canStartHandler(); };