Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
CSS
Priority:
Major
Category:
Task
Assigned:
Reporter:
Created:
1 Jul 2015 at 20:42 UTC
Updated:
21 Oct 2015 at 01:34 UTC
Jump to comment: Most recent, Most recent file
The one major problem most users encountered on mobile devices was the automatic zoom when you focus on a text input. This removed the padding around the edge of the page, making it tricky to scroll without accidentally triggering another input.
It's simple to fix. Set all text inputs to 16px
Implement the CSS fix
Test
No automatic zoom when focusing on text content
None
None
| Comment | File | Size | Author |
|---|---|---|---|
| #39 | prevent_mobile_browsers-2516918-39.patch | 406 bytes | vulcanr |
| #36 | prevent_mobile_browsers-2516918-36.patch | 407 bytes | vulcanr |
| #32 | prevent_auto_zoom_in_mobile-2516918-32.patch | 1.24 KB | pazhyn |
| #28 | prevent_auto_zoom_in_mobile-2516918-28.patch | 535 bytes | pazhyn |
| #16 | prevent_auto_zoom_in_mobile-2516918-16.patch | 2.08 KB | merilainen |
Comments
Comment #1
merilainen commentedThis patch will set the font-size to 16px in mobile for both Seven and Bartik themes. I have also made the selector in CKEditor's CSS more specific, because it was overridden with plain body selector.
Comment #2
lewisnymanNice investigating. Thanks!
If we are changing this selector, can we change the one above it outside of the media query so it matches? Then it would be clear they are the same element.
I like the comments but could we keep using ems instead of pixels? It's possible to change your base font size in mobile browsers so I think we should maintain the use of ems.
Comment #3
merilainen commentedI believe the whole idea of using 16px is to tell the browser to use it strictly without scaling or zooming. That value was already used in the css file, I just made the selector more specific so that it won't be overridden by elements.css.
Here is another patch which unifies the selectors.
Comment #4
merilainen commentedComment #5
zeeshan_khan commented@mErilainen - I agree with #3, changing status to RTBC.
Thanks for the Investigation :)
Comment #6
lewisnymanThis change doesn't just affect zooming, it affects the font size of all inputs in the UI. The UI font size should scale with the user selection, right? If I make my font size really big, the text input font size should also be really big, not just 16px.
Comment #7
merilainen commentedSo, let's try with em values then.
Comment #8
lewisnymanGreat! Thanks. I can confirm that this prevents zooming on mobile inputs.

Comment #9
wim leersWhy these selector changes?
This feels very brittle.
Won't this only yield the desired effect in Seven?
Why did this not work?
Comment #10
merilainen commentedAll of your questions have answers in the comments. I'm not experienced core contributor, should I summarize the changes in the description? There aren't that many comments though, yet...
1. CKEditor's ckeditor-iframe.css's plain body selector is currently overridden by elements.css (which comes from Bartik theme, it should be Seven when editing content, right?), which reduces the font-size to under 16px, which in turn makes at least iOS Safari to use auto zoom. Don't know why though.
2. Lewis preferred the use of ems instead of px values, and that is the equivalent to 15px, at least when using Seven.
3. See #2.
Comment #11
wim leersAFAICT none of those 3 things were actually said before? In any case: thanks!
body.cke_editable, because nested editables may also use.cke_editable, B) document why this more specific selector is necessary.AFAICT Lewis only asked for
emin Bartik's CSS (see #2), not inckeditor-iframe.css. Lewis, can you chime in here?Comment #12
lewisnyman1. If we have two elements that share the same class, can we use two separate classes instead? It's very fragile, our CSS standards recommend that we use element-agnostic selectors.
2. From what I understand, we shouldn't be using pixels for font sizes anywhere. We don't have official guidelines for this yet, but the decision leans towards ems or rems: #2298015: [policy] Document when we should use each CSS unit
Comment #13
wim leers<body>tag that CKEditor uses in its<iframe>. As I said, CKEditor may actually use the.cke_editableclass in a nested manner, so using just the.cke_editableclass is dangerous, because it may end up styling unintended elements too!ckeditor.module. Which means it will run in all themes. So, we need the solution that works always, regardless of theme, and thus regardless of other CSS.I don't know CSS well enough to be able to say which solution is best to guarantee
16pxregardless of theme. But whichever one that is, is the one that should be used.In short: the normal rules don't apply, just like they don't apply to Toolbar. Because both Toolbar and CKEditor appear in many themes, and Toolbar must always look the same, and so should CKEditor iframe instances. (It is up to themes to specify
ckeditor_stylesheetsin their.info.ymlfiles to override the defaults, which Bartik already does.)Comment #14
merilainen commentedHere is a new patch which doesn't touch the font-sizes of CKEditor CSS, it only has the more specific selectors.
Comment #15
wim leersNit: s/overriden/overridden/
Leaving at NR for Lewis.
Comment #16
merilainen commentedFixed typo.
Comment #17
lewisnyman@Wim Ok great, thanks for addressing my concerns.
@mErilainen Thanks for your work! Even with our nitpicking ;-)
Comment #18
wim leersIndeed, thanks! :)
Comment #21
wim leersFailed due to a known random fail.
Comment #23
wim leersSame random fail again. DrupalCI is green.
This is a CSS-only patch, which further proves this is a random failure.
Comment #25
catchWhy are we using px in ckeditor and em in Bartik?
Also could the 1.2307em comment explicitly mention ios? If I google '16px IOS' I get results referring to this magic number. If I google 1.2307em IOS not so much.
Comment #26
wim leersAFAIK because Bartik is a theme and chooses to be em-based, whereas the CKEditor iframe CSS is not a theme at all, it's for an iframe after all. The CKEditor iframe CSS is loaded in every CKEditor iframe (non-inline) instance. However, front-end themes can optionally specify "CKEditor stylesheets", to make the CKEditor iframe instance's styling match that on the front-end as closely as possible.
16px is indeed "the magic number".
1.2307em is just the value that is relative to the other em-values in Bartik (container elements' em-value all affect this one; this is the magical value that then corresponds to 16px).
But I'm sure LewisNyman will explain them em-stuff ten times better :)
Comment #27
catchRight this is the bit I think needs documenting in once place. So it goes straight from 1.2307em = 16px = magic number for IOS zooming. Not 1.2307em = "no mobile zooming" with no explanation as to why.
Also is 16px a magic number on Android too? Was Android tested?
Comment #28
pazhyn commentedThere are only two popular hacks to prevent browser scaling for inputs - magic 16px font-size and disabling user scaling.
As 16px is not ok I tried to change viewport.
Comment #29
pazhyn commentedComment #30
pazhyn commentedComment #32
pazhyn commentedComment #33
dpetruk commentedThis is good solution and it will fix a lot of different bugs on mobile.
And we must be sure that mobile view is comfortable for all people, because it will remove possibility scaling website.
Also disadvantage of this method it don't supporting Android default browse version < 4.2.
And, please, correct "user-scalable: 0" to "user-scalable: no")
Comment #34
lewisnymanWe should not disable user zooming for all Drupal sites. There are two many use cases to assume that a user will never need to zoom. Can we just add a comment to the patch in #16 please?
Comment #35
vulcanr commentedI'll be working on that during #Drupalcon2015 Barcelona
Comment #36
vulcanr commentedMade the change, implemented font-size:1.2em (to keep using ems). The previous patch was blocking the general zoom of the site blocking the viewport.
Comment #37
janmilinds commentedI'm going to review this issue in DrupalCon mentored sprint
Comment #38
janmilinds commentedI reviewed patch in comment #36 and noticed it didn't work at least on login form as it's keeps zooming the view as I move focus to input field.
Comment #39
vulcanr commentedfixed again, using em's somehow forces the device to zoom, so font-size is 16px. Pending for review.
Comment #41
serg2 commentedThe container (div etc) and the font's scaling effects the final font size so in this case 1.2em isn't sufficient to prevent the zoom.
The patch in #16 was pretty solid so might be worth using as a base. It used 1.2307em rather than 1.2em and prevents input zoom on seven, bartik and CKEditor input forms. As far as I understood, it needed some documentation and testing on Android.
Comment #42
lewisnymanThis patch is missing a lot of the changes from #16. Is this intentional?
Comment #43
vulcanr commentedBecause the changes from #16 are used for the ckeditor in the admin panel. The changes in the #39 are for the client side theme. Again, em's are not quite usefull for mobile devices, better to put fixed pixels
Comment #44
vulcanr commentedPlease once again, review and test :)
Comment #45
lewisnymanI don't want to hold this up but honestly I think it makes a difference here to use pixels instead of ems. It means that the font size won't scale with the chosen font size. If someone increases their font size, then the font size won't increase. Maybe we can use 1rem here to make it less fragile?
Comment #46
vulcanr commentedI also tried with rems and it still zooms (at least i tested in an iPhone 6 Plus), but tested at DrupalCon Barcelona with 16px and it doesn't zoom in any device, so, I think that could be nice if someone test the patch, and make the final review to it.
Comment #47
lewisnymanOk thanks. It sounds like we've exhausted all the possible options. Let's get this bug fixed before RC!
Comment #48
wim leersComment #49
vulcanr commentedthanks!
Comment #50
alexpottDiscussed with @xjm and given the discussion on-issue and the fact this is a usability improvement that improves mobile forms I think it is okay to commit at this late stage. Credited the UMN 2015 team too.
Committed ab90199 and pushed to 8.0.x. Thanks!