bug: iPhone "Request Desktop Website" still shows the mobile layout (the page's viewport setting keeps it phone-width)
Back to our planSummary
On an iPhone 16, "Request Desktop Website" still shows the mobile layout, even after #545 (which lowered the desktop breakpoint to 960px and is live). The phone seems to keep laying the page out at its own width (about 393px) because the site tells browsers width=device-width, so no breakpoint can help.
Problem
Reported by Amine on 2026-11-01 (Claude in Chrome side panel): after refreshing and requesting the desktop site on his iPhone 16, he kept getting the mobile version.
What is known and what is not:
- The site never checks the device; the page is the same HTML for everyone and the layout depends on the browser's width.
- #545 assumed a phone's desktop mode lays the page out about 980px wide. That was an inference, and the iPhone shows it doesn't fix this. The cause is most likely that iOS Safari keeps honoring the page's
<meta name="viewport" content="width=device-width, initial-scale=1">in desktop mode, so the page is still laid out about 393px wide. This has not been confirmed on a device. - In desktop mode Safari presents itself as a Mac (the user agent says
Macintosh, with no "iPhone"), withnavigator.maxTouchPointsof 5, andscreen.widthstays the phone's (about 393). iPads in the same mode havescreen.widthof 744 or more, so the two are distinguishable. Source: an unverified write-up of documented behaviour, https://github.com/YurtOS/yurt-playground/issues/214, opens in a new tab, so the fix is built to be checked on the phone.
Proposed fix
A small script in the page head (like the existing theme script) that runs before the page is shown: when the browser says Macintosh, has a touchscreen, and the screen is under 500px, it sets the viewport meta to width=1024. The phone then lays the page out 1024px wide and shrinks it to fit, the same as a "desktop site" on any phone. Real Macs have no touchscreen, iPads are wider than 500px, and phones in normal mode say "iPhone", so none of them are affected.
Native-first check: the browser's own control is the request; the only code needed is the viewport override, so no plugin applies. Reading the user agent on the server isn't an option because the pages are cached and shared.
Acceptance criteria
- Not done: A test covers: iPhone in desktop mode gets
width=1024; an iPad in desktop mode, an iPhone in normal mode, and a Mac without touch don't. - Not done: In a phone-sized browser with a Mac user agent and touch, the page lays out 1024px wide and shows the desktop navigation (checked in a browser).
- Not done: Without the desktop user agent, nothing changes (checked in a browser).
- Not done: On Amine's iPhone 16, requesting the desktop site shows the desktop layout (only he can confirm this).
- Not done: Parent: #190. The PR carries the
shared-componentlabel.
Area
frontend
Priority
priority: medium
Generated by Claude Code, opens in a new tab