-
Notifications
You must be signed in to change notification settings - Fork 324
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
Make form elements scale correctly when text resized by user #1574
Conversation
I think we may need to consider compatibility mode. Our font scaling approach does something like this: Compatibility mode turned off: .input {
font-size: 16px;
} Compatibility mode turned on: .input {
font-size: 16px;
font-size: 1rem;
} If you have a look with legacy mode turned on everything is a lil squsho since GOV.UK Template sets it's root font size to 50% percent (or something close) https://govuk-frontend-review-pr-1574.herokuapp.com/examples/form-alignment?legacy=1 |
Good shout. I think we could mirror what we do in the typography helpers: govuk-frontend/src/govuk/helpers/_typography.scss Lines 146 to 148 in 882333f
We could probably tie it to the same flag, as in theory we only need to resize the box if the font-size is in em. So maybe something like: .whatever {
height: 40px;
@if $govuk-typography-use-rem {
height: govuk-px-to-rem(40px);
}
} Thoughts? |
It feels like we're stretching that variable a bit, but considering this is all related to the scaling of the typography, I think we'll get away with it... 🙏 |
WCAG 2.1 requires that user can resize text to at least 200%. The current versions of `<select>` and `<input>` do not scale well when text is resized by user as setting height in pixels constraints them to that size. Changing the height to use `rem` relative units makes them scalable.
140a56a
to
9123362
Compare
Thanks both for the good suggestions 👍 |
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.
Really thorough investigation and write-up, @hannalaakso – top stuff 👏
The resizing of text docs is very good to know too thanks |
This was introduced in August 2019 [1] to mitigate an issue in GOV.UK Frontend where the height of a select component was set in pixels, which meant it did not scale if users changed the text size in their browser [2]. That issue was fixed in GOV.UK Frontend [3] and released as part of v3.3.0 [4] in October 2019. Since then the height of a select component has been set in rem (as long as compatibility mode is not enabled) which means this adjustment can be removed. [1]: #1018 [2]: alphagov/govuk-frontend#1519 [3]: alphagov/govuk-frontend#1574 [4]: https://github.com/alphagov/govuk-frontend/releases/tag/v3.3.0#:~:text=Pull%20request%20%231574%3A%20Make%20form%20elements%20scale%20correctly%20when%20text%20resized%20by%20user.
Requirement
WCAG 2.1 requires that user can resize text to at least 200%.
Fix
The current versions of
<select>
and<input>
do not scale well when text is resized by user as they're constrained byheight
set in pixels. Changing the height to userem
relative units makes them scalable.Thanks @NickColley and @andysellick for the suggestion to use relative units.
Chrome 76, with text resized to 200%
Before
After
Firefox 69, with text resized to 200%:
Before
After
Safari 12.1, with text resized to 200%:
Before
After
IE11, with text resized to Largest:
Before
After
Fixes #1519
How text was resized in browsers
Chrome
Settings > Appearance > Customise fonts
Firefox
Set View > Zoom > Zoom text only. Press +/-
or Preferences > Language and appearance > Font size
Safari
To increase the font size, press Option-Command-Plus sign (+)
To decrease the font size, press Option-Command-Minus sign (-)
Edge
Can't resize text apart from "Reading view" which removes form elements from the view.
IE 8-11
Page > Text size > Largest
iOS
Text can't resized in browser. See #882
Android Chrome/Firefox
Settings > Accessibility > Text scaling