The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): improve font-size slider performance and prevent maximum update depth errors (#7138)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
berna committed
Sep 7, 2026 at 01:26 UTC
062987b2fb0ef48cc7776d654931bd9f3bcf1f9f
1 file changed
+12
-9
apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.tsx
+12
-9
@@ -52,11 +52,12 @@ export function FontSizeSliderRow(props: {
52
}, [dragging, fraction, progress]);
53
54
const commit = useCallback((next: number) => {
55
- if (next === latest.current.value) {
55
+ const current = latest.current;
56
+ if (next === current.value) {
57
return;
58
}
59
Haptics.selectionAsync().catch(() => undefined);
59
- latest.current.onChange(next);
60
+ current.onChange(next);
61
}, []);
62
63
const gesture = useMemo(() => {
@@ -90,17 +91,19 @@ export function FontSizeSliderRow(props: {
91
dragging.value = true;
92
const f = fractionAt(event.x);
93
progress.value = f;
93
- runOnJS(commit)(valueAtFraction(f));
94
})
95
- .onFinalize(() => {
95
+ .onFinalize((_event, success) => {
96
if (!dragging.value) {
97
return;
98
}
99
dragging.value = false;
100
- progress.value = withTiming(
101
- fractionOfValue(valueAtFraction(progress.value)),
102
- SNAP_ANIMATION,
103
- );
100
+ if (!success) {
101
+ progress.value = withTiming(fractionOfValue(value), SNAP_ANIMATION);
102
+ return;
103
+ }
104
+ const next = valueAtFraction(progress.value);
105
+ progress.value = withTiming(fractionOfValue(next), SNAP_ANIMATION);
106
+ runOnJS(commit)(next);
107
});
108
109
const tap = Gesture.Tap()
@@ -112,7 +115,7 @@ export function FontSizeSliderRow(props: {
115
});
116
117
return Gesture.Race(pan, tap);
115
- }, [commit, disabled, dragging, max, min, progress, step, trackWidth]);
118
+ }, [commit, disabled, dragging, max, min, progress, step, trackWidth, value]);
119
120
const fillStyle = useAnimatedStyle(() => ({
121
width: THUMB_SIZE / 2 + progress.value * Math.max(0, trackWidth.value - THUMB_SIZE),