Skip to content

Commit 1aec1e7

Browse files
committed
fix: apply native Android paragraph direction to thread titles
1 parent c94fc83 commit 1aec1e7

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎apps/mobile/src/features/threads/thread-list-v2-items.tsx‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { canSnooze } from "@t3tools/client-runtime/state/thread-settled";
3131
import { threadChipCopyTarget } from "@t3tools/client-runtime/thread-reference";
3232
import type { MenuAction } from "@react-native-menu/menu";
3333
import { memo, useCallback, useMemo, useState, type ComponentProps } from "react";
34-
import { Pressable, useWindowDimensions, View, type TextStyle } from "react-native";
34+
import { Platform, Pressable, useWindowDimensions, View, type TextStyle } from "react-native";
3535
import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
3636

3737
import type { ThreadListProvider } from "../../state/thread-list-environments";
@@ -91,6 +91,14 @@ function textDirectionStyle(text: string) {
9191
} satisfies TextStyle;
9292
}
9393

94+
function directionalTitle(text: string) {
95+
const direction = textDirection(text);
96+
// Android ignores writingDirection; a render-only mark sets its first-strong paragraph direction.
97+
return Platform.OS === "android" && direction
98+
? `${direction === "rtl" ? "\u200f" : "\u200e"}${text}`
99+
: text;
100+
}
101+
94102
interface StatusLabel {
95103
readonly label: string;
96104
readonly icon: AppSymbolName;
@@ -476,7 +484,7 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
476484
numberOfLines={1}
477485
style={textDirectionStyle(pendingTask.title)}
478486
>
479-
{pendingTask.title}
487+
{directionalTitle(pendingTask.title)}
480488
</Text>
481489
{branch || props.environmentLabel ? (
482490
<View className="mt-1 flex-row items-center gap-1">
@@ -1093,7 +1101,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
10931101
numberOfLines={2}
10941102
style={textDirectionStyle(thread.title)}
10951103
>
1096-
{thread.title}
1104+
{directionalTitle(thread.title)}
10971105
</Text>
10981106
<View className="flex-row items-center gap-1.5" style={{ minHeight: titleLineHeight }}>
10991107
{props.hasQueuedMessages ? <QueuedMessageIcon selected={selected} /> : null}
@@ -1385,7 +1393,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
13851393
numberOfLines={1}
13861394
style={textDirectionStyle(thread.title)}
13871395
>
1388-
{thread.title}
1396+
{directionalTitle(thread.title)}
13891397
</Text>
13901398
{props.searchMatch ? (
13911399
<ThreadSearchMatchExcerpt

0 commit comments

Comments
 (0)