Opened 41 minutes ago
Last modified 35 minutes ago
#37533 new Bug
Admin calendar and time picker hover/focus style has insufficient contrast in the light theme
| Reported by: | Alin Morosanu | Owned by: | |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Normal | Keywords: | accessibility |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | yes |
Description (last modified by )
In the admin's calendar and time picker, a hovered or keyboard-focused day or time is shown with white text on var(--primary), which is #79aec8 in the light theme. That's a contrast ratio of 2.41:1, below the WCAG 2.1 AA minimum of 4.5:1 for normal text (SC 1.4.3). Calendar days are 12px and time options 13px, both normal weight.
Both use the same rule in django/contrib/admin/static/admin/css/widgets.css (unchanged at c67d872765 on main):
.calendar td a:focus,
.timelist a:focus,
.calendar td a:hover,
.timelist a:hover {
background: var(--primary);
color: white;
}
Computed colours on the demo at https://thibaudcolas.github.io/django_admin_tests/latest/english/admin/auth/user/1/change/ (Django 6.2.dev20261022174430), Chromium 143 on macOS, light theme: white on #79aec8 for both hover and keyboard focus, on a calendar day and on a time option. On current main (c67d872765, run locally in Firefox), a time option reached with Tab has computed white on #79aec8, and Firefox's accessibility inspector shows 2.41 on hover for both a calendar day and a time option. In the dark theme, the same hover/focus pair is white on #264b5d (9.35:1).
Steps to reproduce:
- Open a change form with a date and time field in the light theme, for example a user's "Last login".
- Open the calendar (calendar icon) or the time picker (clock icon), then hover over a day or time, or Tab to one.
Related: #34036 moved .calendar td.selected a to var(--secondary) but left this rule. PR #12967 (for #31617, closed) proposed #609ab6 for this rule, which would still be about 3.09:1. #36192 (PR #21350) changes these selectors from a to button, so a fix would touch the same lines.
Thibaud Colas pointed this out to me on Discord. I'm a Djangonaut in Session 7 and would like to work on it.