Skip to content

Commit 6143e73

Browse files
committed
fix: add 5px safety buffer to chrome maxWidth to prevent title overflow on mobile
The heuristic char-width estimate slightly underestimates real font width at narrow containers, causing titles to clip instead of wrapping. A small buffer ensures the wrap triggers before the text overflows.
1 parent af1fd11 commit 6143e73

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

packages/core/src/layout/__tests__/chrome.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('computeChrome', () => {
104104
const chrome: Chrome = { title: 'Title' };
105105
const result = computeChrome(chrome, theme, 600);
106106

107-
const expectedMaxWidth = 600 - theme.spacing.padding * 2;
107+
const expectedMaxWidth = 600 - theme.spacing.padding * 2 - 5;
108108
expect(result.title!.maxWidth).toBe(expectedMaxWidth);
109109
});
110110

packages/core/src/layout/chrome.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ export function computeChrome(
182182

183183
const pad = padding ?? theme.spacing.padding;
184184
const chromeGap = theme.spacing.chromeGap;
185-
const maxWidth = width - pad * 2;
185+
// Subtract a small buffer beyond padding so the heuristic char-width
186+
// estimate triggers word-wrap before the real font overflows the container.
187+
const WRAP_SAFETY_BUFFER = 5;
188+
const maxWidth = width - pad * 2 - WRAP_SAFETY_BUFFER;
186189
const fontFamily = theme.fonts.family;
187190

188191
// Track vertical cursor for top elements

0 commit comments

Comments
 (0)