Skip to content
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

Merged
merged 2 commits into from
Sep 16, 2019

Conversation

hannalaakso
Copy link
Member

@hannalaakso hannalaakso commented Sep 13, 2019

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 by height set in pixels. Changing the height to use rem relative units makes them scalable.

Thanks @NickColley and @andysellick for the suggestion to use relative units.

Chrome 76, with text resized to 200%

Before

chrome-before
chrome-before-2

After

Screen Shot 2019-09-13 at 14 48 10

Screen Shot 2019-09-13 at 14 48 20

Firefox 69, with text resized to 200%:

Before

ff-before
firefox-before-2

After

Screen Shot 2019-09-13 at 15 20 04

Screen Shot 2019-09-13 at 15 23 20

Safari 12.1, with text resized to 200%:

Before

safari-before
safari-before-2

After

Screen Shot 2019-09-13 at 15 20 47

Screen Shot 2019-09-13 at 15 20 41

IE11, with text resized to Largest:

Before

edge-before
ie11-before-2

After

Screen Shot 2019-09-13 at 15 21 52

Screen Shot 2019-09-13 at 15 22 06

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

@hannalaakso hannalaakso added this to Needs review in Design System Sprint Board via automation Sep 13, 2019
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1574 September 13, 2019 14:34 Inactive
@NickColley
Copy link
Contributor

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

@36degrees
Copy link
Member

I think we may need to consider compatibility mode.

Good shout. I think we could mirror what we do in the typography helpers:

@if $govuk-typography-use-rem {
font-size: $font-size-rem; // sass-lint:disable no-duplicate-properties
}

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?

@NickColley
Copy link
Contributor

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.
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1574 September 13, 2019 14:55 Inactive
@hannalaakso
Copy link
Member Author

Thanks both for the good suggestions 👍

Copy link
Member

@36degrees 36degrees left a 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 👏

@NickColley
Copy link
Contributor

The resizing of text docs is very good to know too thanks

@hannalaakso hannalaakso merged commit bf8bedf into master Sep 16, 2019
Design System Sprint Board automation moved this from Needs review to Done Sep 16, 2019
@hannalaakso hannalaakso deleted the make-form-elements-scalable branch September 16, 2019 08:20
@NickColley NickColley added this to the Next milestone Sep 16, 2019
@hannalaakso hannalaakso moved this from Done to Ready to release in Design System Sprint Board Sep 19, 2019
@36degrees 36degrees mentioned this pull request Oct 7, 2019
@NickColley NickColley mentioned this pull request Oct 7, 2019
@NickColley NickColley moved this from Ready to release to Done in Design System Sprint Board Oct 7, 2019
36degrees added a commit to alphagov/govuk_publishing_components that referenced this pull request Jun 1, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Form elements do not scale well if only font size increased
4 participants