-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent automatic zoom when focusing inputs on iOS #8477
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR implements a solution to prevent automatic zooming on iOS devices when users focus on input fields with font sizes smaller than 16px, while maintaining manual zoom functionality.
- Added inline JavaScript in
/packages/twenty-front/index.html
to detect iOS devices and setmaximum-scale=1.0
viewport property - Moved viewport meta tag placement for optimal timing of zoom prevention
- Solution preserves manual zoom capability while preventing disruptive auto-zoom behavior
- Implementation uses progressive enhancement approach, only applying changes to detected iOS devices
- Addresses reported UX issues with input fields, dropdowns, and page scrolling on iOS devices
1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
} | ||
} | ||
|
||
const isIOS = /iPad|iPhone/.test(navigator.userAgent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: User agent detection can be unreliable. Consider using feature detection or multiple iOS detection methods for better reliability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Just to recap for to leave the full conclusion in one place, in my opinion disabling zoom on Android is a better option from a product/design perspective since our business goal is to have an app-like behavior (it's also better from a code perspective imo since it's just a one-line change), but we've spent more than enough time debating this - let's merge this.
Log
|
This is the result of a long discussion we had here: #8001.
The goal is to stop iOS from automatically zooming when the user focuses on an input whose font size is less than 16px.
The options were:
To me, the second option is the best, as iOS prevents developers from disabling zoom. They saw that it was overused and chose to restrict this setting. Setting a
maximum-scale
doesn't prevent users from zooming, but it fixes the initial bug we had.My implementation can be seen as progressive enhancement: If we can detect that the user uses an iOS device, we'll set the
maximum-scale
viewport property. Relying on the user agent is always unstable, and the check might fail unpredictably. We might not disallow auto-zoom for some iOS devices.However, I think we can either:
I know my JavaScript code does not follow a pattern we want to spread in the app. The synchronous script will run as soon as possible to ensure the viewport is correctly set when the website launches. This shouldn't be an example followed by others.
Thanks, @harshit078, for your help in thinking about the best option.
I'm tagging @lucasbordeau and @charlesBochet for a technical review.
I would appreciate if someone could test on a more recent iOS device than mine.
Here is a demonstration of the behavior on iOS:
RPReplay_Final1731503005.4.MP4