Skip to content

Commit 4aef2b0

Browse files
pchalupameta-codesync[bot]
authored andcommitted
Set max font scaling in LogBox to avoid layout breaking (#57333)
Summary: Fixes `LogBox` layout while using accessibility font multiplier. I was aiming for the highest possible value without breaking the UI. Max scales are mostly set to 1.5 and less when needed. <img width="1206" height="2622" alt="Simulator Screenshot - iPhone 17 Pro - 2026-05-04 at 19 39 35" src="https://github.com/user-attachments/assets/f59b426b-44fe-4ad0-bb52-2e9ee286073e" /> <img width="1206" height="2622" alt="Simulator Screenshot - iPhone 17 Pro - 2026-05-04 at 19 39 47" src="https://github.com/user-attachments/assets/b4b4d871-f21b-45b2-accf-be1b58e6c881" /> <img width="1206" height="2622" alt="Simulator Screenshot - iPhone 17 Pro - 2026-05-04 at 19 39 40" src="https://github.com/user-attachments/assets/006dd5bb-4525-491c-8f3f-ddcd211615da" /> <img width="1206" height="2622" alt="Simulator Screenshot - iPhone 17 Pro - 2026-05-04 at 19 41 01" src="https://github.com/user-attachments/assets/d7029511-878c-4c0b-a7d0-b7c7a6abaa9c" /> https://github.com/user-attachments/assets/507ba38d-6338-4e33-b3d0-cbf54e108ac3 ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [GENERAL] [FIXED] - Set max font scaling in `LogBox` to avoid layout breaking Pull Request resolved: #57333 Test Plan: 1. Set the max text size on your testing device. 2. Log or throw an error in the playground. Reviewed By: ellemac123 Differential Revision: D110045786 Pulled By: javache fbshipit-source-id: cdd94437a54443a04d724f250c4b5ac1da059b34
1 parent 2468e3c commit 4aef2b0

14 files changed

Lines changed: 80 additions & 23 deletions

packages/react-native/Libraries/LogBox/UI/AnsiHighlight.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default function Ansi({
8787
<View style={styles.container}>
8888
{parsedLines.map((items, i) => (
8989
<View style={styles.line} key={i}>
90-
<Text style={styles.text}>
90+
<Text maxFontSizeMultiplier={1.5} style={styles.text}>
9191
{items.map((bundle, key) => {
9292
const textStyle =
9393
bundle.fg && COLORS[bundle.fg]
@@ -101,6 +101,7 @@ export default function Ansi({
101101
return (
102102
<Text
103103
id="logbox_codeframe_contents_text"
104+
maxFontSizeMultiplier={1.5}
104105
style={[style, textStyle]}
105106
key={key}>
106107
{getText(bundle.content, key)}

packages/react-native/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ component CodeFrameDisplay(codeFrame: CodeFrame) {
6363
onPress={() => {
6464
openFileInEditor(codeFrame.fileName, codeFrame.location?.row ?? 0);
6565
}}>
66-
<Text style={styles.fileText}>
66+
<Text maxFontSizeMultiplier={1.5} style={styles.fileText}>
6767
{getFileName()}
6868
{getLocation()}
6969
</Text>
@@ -116,7 +116,7 @@ component AppInfo() {
116116
}}
117117
style={appInfoStyles.buildButton}
118118
onPress={appInfo.onPress}>
119-
<Text style={appInfoStyles.text}>
119+
<Text maxFontSizeMultiplier={1.5} style={appInfoStyles.text}>
120120
{appInfo.appVersion} ({appInfo.engine})
121121
</Text>
122122
</LogBoxButton>

packages/react-native/Libraries/LogBox/UI/LogBoxInspectorFooter.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export default function LogBoxInspectorFooter(props: Props): React.Node {
2929
return (
3030
<View style={styles.root}>
3131
<View style={styles.button}>
32-
<Text id="logbox_dismissable_text" style={styles.syntaxErrorText}>
32+
<Text
33+
id="logbox_dismissable_text"
34+
maxFontSizeMultiplier={1.5}
35+
style={styles.syntaxErrorText}>
3336
This error cannot be dismissed.
3437
</Text>
3538
</View>

packages/react-native/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export default function LogBoxInspectorFooterButton(
3535
}}
3636
onPress={props.onPress}>
3737
<View style={styles.buttonContent}>
38-
<Text style={styles.buttonLabel}>{props.text}</Text>
38+
<Text maxFontSizeMultiplier={1.5} style={styles.buttonLabel}>
39+
{props.text}
40+
</Text>
3941
</View>
4042
</LogBoxButton>
4143
</SafeAreaView>

packages/react-native/Libraries/LogBox/UI/LogBoxInspectorHeader.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export default function LogBoxInspectorHeader(props: Props): React.Node {
3636
<LogBoxInspectorHeaderSafeArea style={styles[props.level]}>
3737
<View style={styles.header}>
3838
<View style={styles.title}>
39-
<Text style={styles.titleText} id="logbox_header_title_text">
39+
<Text
40+
id="logbox_header_title_text"
41+
maxFontSizeMultiplier={1.5}
42+
style={styles.titleText}>
4043
Failed to compile
4144
</Text>
4245
</View>
@@ -63,7 +66,10 @@ export default function LogBoxInspectorHeader(props: Props): React.Node {
6366
onPress={() => props.onSelectIndex(prevIndex)}
6467
/>
6568
<View style={styles.title}>
66-
<Text style={styles.titleText} id="logbox_header_title_text">
69+
<Text
70+
id="logbox_header_title_text"
71+
maxFontSizeMultiplier={1.5}
72+
style={styles.titleText}>
6773
{titleText}
6874
</Text>
6975
</View>

packages/react-native/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ component LogBoxInspectorMessageHeader(
3232
return null;
3333
}
3434
return (
35-
<Text style={messageStyles.collapse} onPress={() => onPress()}>
35+
<Text
36+
maxFontSizeMultiplier={1.5}
37+
style={messageStyles.collapse}
38+
onPress={() => onPress()}>
3639
... See More
3740
</Text>
3841
);
@@ -42,12 +45,16 @@ component LogBoxInspectorMessageHeader(
4245
<View style={messageStyles.body}>
4346
<View style={messageStyles.heading}>
4447
<Text
48+
maxFontSizeMultiplier={1.5}
4549
style={[messageStyles.headingText, messageStyles[level]]}
4650
id="logbox_message_title_text">
4751
{title}
4852
</Text>
4953
</View>
50-
<Text style={messageStyles.bodyText} id="logbox_message_contents_text">
54+
<Text
55+
maxFontSizeMultiplier={1.5}
56+
style={messageStyles.bodyText}
57+
id="logbox_message_contents_text">
5158
<LogBoxMessage
5259
maxLength={collapsed ? SHOW_MORE_MESSAGE_LENGTH : Infinity}
5360
message={message}

packages/react-native/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,24 @@ component LogBoxInspectorReactFrames(log: LogBoxLog) {
101101
<View style={componentStyles.component}>
102102
<Text
103103
id="logbox_component_stack_frame_text"
104+
maxFontSizeMultiplier={1.5}
104105
style={componentStyles.frameName}>
105-
<Text style={componentStyles.bracket}>{'<'}</Text>
106+
<Text
107+
maxFontSizeMultiplier={1.5}
108+
style={componentStyles.bracket}>
109+
{'<'}
110+
</Text>
106111
{frame.methodName}
107-
<Text style={componentStyles.bracket}>{' />'}</Text>
112+
<Text
113+
maxFontSizeMultiplier={1.5}
114+
style={componentStyles.bracket}>
115+
{' />'}
116+
</Text>
108117
</Text>
109118
</View>
110-
<Text style={componentStyles.frameLocation}>
119+
<Text
120+
maxFontSizeMultiplier={1.5}
121+
style={componentStyles.frameLocation}>
111122
{frame.file != null ? getPrettyFileName(frame.file) : ''}
112123
{frame.lineNumber != null ? `:${frame.lineNumber}` : ''}
113124
</Text>
@@ -122,7 +133,9 @@ component LogBoxInspectorReactFrames(log: LogBoxLog) {
122133
}}
123134
onPress={() => setCollapsed(!collapsed)}
124135
style={componentStyles.collapseButton}>
125-
<Text style={componentStyles.collapse}>{getCollapseMessage()}</Text>
136+
<Text maxFontSizeMultiplier={1.5} style={componentStyles.collapse}>
137+
{getCollapseMessage()}
138+
</Text>
126139
</LogBoxButton>
127140
</View>
128141
</LogBoxInspectorSection>

packages/react-native/Libraries/LogBox/UI/LogBoxInspectorSection.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ component LogBoxInspectorSection(
2222
return (
2323
<View style={styles.section}>
2424
<View style={styles.heading}>
25-
<Text style={styles.headingText}>{heading}</Text>
25+
<Text maxFontSizeMultiplier={1.5} style={styles.headingText}>
26+
{heading}
27+
</Text>
2628
{action}
2729
</View>
2830
<View style={styles.body}>{children}</View>

packages/react-native/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ component LogBoxInspectorSourceMapStatus(
103103
: {transform: [{rotate: state.rotate}]},
104104
]}
105105
/>
106-
<Text style={[styles.text, {color}]}>Source Map</Text>
106+
<Text maxFontSizeMultiplier={1.5} style={[styles.text, {color}]}>
107+
Source Map
108+
</Text>
107109
</LogBoxButton>
108110
);
109111
}

packages/react-native/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ component LogBoxInspectorStackFrame(
4444
style={styles.frame}>
4545
<Text
4646
id="logbox_stack_frame_text"
47+
maxFontSizeMultiplier={1.5}
4748
style={[styles.name, frame.collapse === true && styles.dim]}>
4849
{frame.methodName}
4950
</Text>
5051
<Text
5152
ellipsizeMode="middle"
53+
maxFontSizeMultiplier={1.5}
5254
numberOfLines={1}
5355
style={[styles.location, frame.collapse === true && styles.dim]}>
5456
{location}

0 commit comments

Comments
 (0)