Back to writing

RTL is a test dimension, not a CSS property

People treat right-to-left support as a styling task. Flip a few textAlign values, mirror some padding, ship it. That is the part you can see in a static mockup, and it is the smallest part.

Hebrew changes behavior. Navigation reverses: back moves the other way, the next item in a row sits to the left, a pager advances toward the start of the line. Gestures invert with it: a swipe that meant forward in English now means backward. And the layout engine itself behaves differently in RTL, sometimes in ways the docs do not spell out. So RTL is a dimension you test across, the same way you test across screen sizes and font scales.

I learned the engine part the hard way, and the test part later than I thought I had: two Maestro flows walked the broken carousel and stayed green the whole time, because they only ever ran it in English.

One locale broken, same component

In the onboarding carousel of Homies, the bilingual React Native app I build on the side, English was fine. Hebrew was not. The carousel rendered the first and last slides dimmed to invisible and only the middle slide showed its content. The Next button ping-ponged between the first two slides and never reached the end. Same component, same data, one locale broken.

A carousel that cannot advance is the first thing a Hebrew user touches, and it traps them on slide one of onboarding.

Fabric reads LTR and writes RTL

The carousel pinned its FlatList to a wrapper forced to direction: 'ltr'. That is a common trick: keep the scroll math in one coordinate system and mirror the content yourself. The trick has a sharp edge under the New Architecture.

Under Fabric, the two halves of scrolling do not agree on which way is positive. Scroll reads come back already un-mirrored: event.contentOffset.x reports the value as if the list were LTR, even in a Hebrew layout. Scroll writes are the opposite: scrollToOffset still interprets its offset in mirrored native space. Reads speak LTR. Writes speak RTL. Nothing in the API surface tells you that.

The old code did not know this. Its comments said the native scroll view "still reports a mirrored contentOffset.x", and it applied the same RTL correction to both sides. On the read side it computed maxOffset - x on a value that Fabric had already un-mirrored, double-flipping it. The doubled offset drove the parallax and opacity interpolators straight to their clamped extremes, which is why every slide but the center dimmed out. The same double-flip wrecked index detection, which is why Next could not count past the second slide.

Mirror only the writes

The asymmetry is the whole story, so the fix encodes it directly: read raw, and mirror only on the write side, through one helper that is a no-op in LTR.

  // READ side (onScroll). Before: it
  // flipped an offset Fabric had already
  // un-mirrored, dimming every slide but
  // the center.
- const x = event.contentOffset.x;
- scrollX.value = isRTL
-   ? maxOffset - x
-   : x;
  // After: raw.
+ scrollX.value = event.contentOffset.x;
 
  // Index (onMomentumScrollEnd)
  const x = event.nativeEvent.contentOffset.x;
- const index = Math.round(
-   (isRTL ? maxOffset - x : x) /
-     screenWidth,
- );
+ const index = Math.round(x / screenWidth);
 
  // WRITE side: mirrored in one
  // helper, a no-op in LTR.
+ const toNativeOffset = useCallback(
+   (logicalX: number) =>
+     isRTL
+       ? maxOffset - logicalX
+       : logicalX,
+   [isRTL, maxOffset],
+ );
  flatListRef.current?.scrollToOffset({
    offset: toNativeOffset(targetX),
    animated: true,
  });

Reads pass through untouched. Every write goes through toNativeOffset, which mirrors in Hebrew and does nothing in English. That left exactly one place that knew about mirrored coordinates, on the side that needed it, with the read/write asymmetry written down in comments next to the code.

The flows that passed while it was broken

I believed a guard already existed: a Maestro flow, onboarding/carousel-navigation.yaml, that traversed the carousel slide by slide in Hebrew. Read line by line, it did not do that, and never had.

The flow launched the app with clearState: true, tapped the Next button four times, and asserted that the personalize step appeared. It set no language. At the time, a fresh install started in English: English was the hard default in PreferencesContext, and following the device locale arrived a month later. So the flow walked every slide to the end, in English, which is the locale where the bug did not exist. Its sibling carousel-language-toggle.yaml did tap the globe button, then asserted that the carousel and its Next button were still visible, and toggled back. It never tapped Next in Hebrew.

Both flows were added six days before the fix. They were green the whole time a Hebrew user could not get past slide one, and they would have stayed green if the fix were reverted. The bug was found by hand, and the fix commit says how it was checked: "verified live on the iOS simulator (Hebrew + English)".

That is the title of this post, demonstrated on its author. The flow exercised the right motion in one locale, and I read "walks the carousel" as "guards the carousel". The flow that would have caught it is one step longer: tap the language button first, then walk to the end.

What guards RTL now

Nothing guards horizontal scroll math, because nothing in the app does any. Two weeks after the fix, the first-run redesign deleted OnboardingCarousel.tsx and all three carousel flows: the two above and carousel-skip-join-flow.yaml. The horizontal scrollers left are chip and picker rails in the expense and chore screens, and none of them reads contentOffset or calls scrollToOffset. They let the engine mirror them and do no arithmetic, which is the safe side of the asymmetry. A new pager would arrive with this bug class unguarded.

What does guard RTL as a dimension:

  • src/utils/rtl.ts drives the native layout direction (I18nManager) from the in-app language choice instead of the device locale, so Hebrew on an English phone still gets mirrored navigation and gestures. src/utils/__tests__/rtl.test.ts pins it, including that English stays LTR on an RTL device and that the legacy Android iw tag resolves to Hebrew.
  • src/locales/__tests__/parity.test.ts fails if a concept exists in one locale and not the other, comparing plural bases because Hebrew and English have different CLDR plural categories, and fails if shared keys disagree on their {{placeholders}}.
  • display-name.bidiIsolation.test.tsx asserts that an interpolated name is wrapped in Unicode isolates, so a Latin name inside a Hebrew sentence does not reorder the punctuation around it.
  • .maestro/flows/settings/language-toggle-flow.yaml switches to Hebrew, waits for the app to reload with the settings title in Hebrew, and switches back, so it can stay tagged read-only.

That last flow is the only one that switches the app into Hebrew, and it asserts one title. A few others accept Hebrew text in system dialogs so they survive a Hebrew simulator, but none chooses Hebrew and then exercises a screen. If I were ranking what to add, it is the lesson from above rather than anything about scroll offsets: take flows that already exist and run them a second time after the language toggle.

The short version, with the diff and the files that guard RTL today, is exhibit 2 in the bug museum.