[Django] #35321: Django Admin in Mobile Safari zooms in on text inputs

30 views
Skip to first unread message

Django

unread,
Mar 20, 2024, 10:09:37 PM3/20/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon | Owner: nobody
Willison |
Type: | Status: new
Uncategorized |
Component: | Version: 5.0
contrib.admin | Keywords: css, accessibility,
Severity: Normal | mobile
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 1 |
-------------------------------------+-------------------------------------
The Django Admin on Mobile Safari currently has a bug where tapping on an
input field or textarea causes the screen to zoom in slightly, leaving the
user to zoom back out again when they have finished editing.

This is related to a fix from a while ago where we ensured our meta
viewport didn't restrict zooming - which was a good accessibility change!
https://code.djangoproject.com/ticket/34617

We can fix the zoom by very slightly increasing the font-size used for
these fields. 16px is the magic value that prevents Mobile Safari from
zooming in on a selected field.

I've applied this fix to my own site using a custom template here:
https://github.com/simonw/simonwillisonblog/blob/f5bf2f8fa035c62ef6b373d8237e9bc9e177052d/templates/admin/base_site.html

Here's a demo video I made on my iPhone:
https://static.simonwillison.net/static/2024/mobile-safari-zoom-django-
admin.mov

It shows two Django Admin instances. In the first half of the video I
interact with the default admin, showing how tapping on input text and
textarea fields zooms the screen in slightly.

In the second half of the video I interact with a customized version of
the Admin that sets font-size: 16px on those fields. This removes the
default zoom.

I think we should standardize on 16px for all form fields in the admin.
I've patched a bunch of them on my own instance, but the one thing I
haven't fixed yet is the select2 form field used for e.g. autocompleted
tag entry.
--
Ticket URL: <https://code.djangoproject.com/ticket/35321>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 20, 2024, 10:16:30 PM3/20/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage:
mobile | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Simon Willison):

Here's where the font-size is set for those fields:

https://github.com/django/django/blob/6f7c0a4d66f36c59ae9eafa168b455e462d81901/django/contrib/admin/static/admin/css/responsive.css#L181-L196

It's set to font-size: 0.875rem as-of this change two years ago:
https://github.com/django/django/commit/1f42a352e04d2e63117f067a1432594ffbb6a8b4
- which changed it from the previous font-size of 14px (still small enough
to cause a zoom on Mobile Safari) to using rem values instead.

I believe 1rem would be the equivalent of 16px.

Here's the issue where px was swapped out for rem, to ensure browser font
sizing worked correctly: https://code.djangoproject.com/ticket/33434
--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:1>

Django

unread,
Mar 20, 2024, 10:20:42 PM3/20/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage:
mobile | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Simon Willison):

This change will likely have knock-on effects. Labels are currently set to
0.8125rem - should they be increased to 1rem too?
https://github.com/django/django/blob/6f7c0a4d66f36c59ae9eafa168b455e462d81901/django/contrib/admin/static/admin/css/forms.css#L39-L43
--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:2>

Django

unread,
Mar 20, 2024, 10:22:08 PM3/20/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage:
mobile | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Simon Willison):

I also found these "form defaults" here:
https://github.com/django/django/blob/6f7c0a4d66f36c59ae9eafa168b455e462d81901/django/contrib/admin/static/admin/css/base.css#L471-L478


{{{
input, textarea, select, .form-row p, form .button {
margin: 2px 0;
padding: 2px 3px;
vertical-align: middle;
font-family: var(--font-family-primary);
font-weight: normal;
font-size: 0.8125rem;
}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:3>

Django

unread,
Mar 21, 2024, 12:30:27 AM3/21/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage: Accepted
mobile |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* cc: Thibaud Colas, Sarah Abderemane, Tom Carrick (added)
* stage: Unreviewed => Accepted
* type: Uncategorized => Cleanup/optimization

Comment:

Thanks for the detailed report. I'll leave a specific fix to be discussed
and confirmed by the Accessibility Team.
--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:4>

Django

unread,
Mar 21, 2024, 6:16:32 AM3/21/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage: Accepted
mobile |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Almaz):

So, does this ticket requires some discussion before picking it up?
--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:5>

Django

unread,
Mar 21, 2024, 6:24:00 AM3/21/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage: Accepted
mobile |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Tom Carrick):

16px is probably a good minimum for all (non-small) text in the admin, but
I think restricting this to just labels for now to fix this issue is a
good first step. 1rem is probably the way to go.
--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:6>

Django

unread,
Mar 23, 2024, 9:40:45 PM3/23/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: Jason
Type: | Hall
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage: Accepted
mobile |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Jason Hall):

* owner: nobody => Jason Hall
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:7>

Django

unread,
Mar 24, 2024, 10:03:10 AM3/24/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: Jason
Type: | Hall
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage: Accepted
mobile |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Jason Hall):

Then, can I just add this:

label {
font-size: 1rem;
}

to the base.css file in django/contrib/admin/static/admin/css folder? I
guess I'll try that and see what happens.
--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:8>

Django

unread,
Mar 24, 2024, 10:14:38 AM3/24/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: Jason
Type: | Hall
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage: Accepted
mobile |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Jason Hall):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:9>

Django

unread,
Mar 24, 2024, 11:09:26 AM3/24/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: Jason
Type: | Hall
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage: Accepted
mobile |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:10>

Django

unread,
Mar 25, 2024, 1:00:38 AM3/25/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: Jason
Type: | Hall
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage: Accepted
mobile |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 0 => 1

Comment:

[https://github.com/django/django/pull/18013 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:11>

Django

unread,
Apr 18, 2024, 12:04:40 PM4/18/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: Jason
Type: | Hall
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage: Accepted
mobile |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:12>

Django

unread,
Apr 19, 2024, 4:51:46 AM4/19/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: Jason
Type: | Hall
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution:
Keywords: css, accessibility, | Triage Stage: Ready for
mobile | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:13>

Django

unread,
Apr 19, 2024, 8:36:47 AM4/19/24
to django-...@googlegroups.com
#35321: Django Admin in Mobile Safari zooms in on text inputs
-------------------------------------+-------------------------------------
Reporter: Simon Willison | Owner: Jason
Type: | Hall
Cleanup/optimization | Status: closed
Component: contrib.admin | Version: 5.0
Severity: Normal | Resolution: fixed
Keywords: css, accessibility, | Triage Stage: Ready for
mobile | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"53719d6b5b745dd99b1ab9315afb242f706ebbf1" 53719d6b]:
{{{#!CommitTicketReference repository=""
revision="53719d6b5b745dd99b1ab9315afb242f706ebbf1"
Fixed #35321 -- Prevented Mobile Safari zoom-in on Django admin inputs.

Thanks Simon Willison for the report and Ben Cardy for testing.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35321#comment:14>
Reply all
Reply to author
Forward
0 new messages