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

Form elements do not scale well if only font size increased #1519

Closed
andysellick opened this issue Aug 1, 2019 · 11 comments · Fixed by #1574
Closed

Form elements do not scale well if only font size increased #1519

andysellick opened this issue Aug 1, 2019 · 11 comments · Fixed by #1574
Assignees
Labels
accessibility regulations failure Does not meet the Public Sector Accessibility Regulations (WCAG 2.2 level AA) accessibility 🐛 bug Something isn't working the way it should (including incorrect wording in documentation) ⚠️ high priority Used by the team when triaging

Comments

@andysellick
Copy link
Contributor

If you zoom text only in Firefox, select elements retain their 40px height but the text within them becomes larger and therefore cropped from the bottom edge.

Screen Shot 2019-08-01 at 14 30 10

Doesn't seem to be as much of a problem for text inputs.

Can't reproduce the problem in Chrome because the zoom text only option isn't available.

Noticed this during user testing on a phone of GOV.UK's search, specifically where we have select elements in finders.

(can't remember what kind but possibly an iPhone 7?)

Side note: doing this on the Design System site causes the currently active menu item to be crossed out instead of underlined:

Screen Shot 2019-08-01 at 14 31 28

@NickColley NickColley added the awaiting triage Needs triaging by team label Aug 1, 2019
@andysellick
Copy link
Contributor Author

This appears to be fixable by changing the height from using px to em but I think we already discussed this and there was a reason not to do it? Can someone remind me?

@NickColley
Copy link
Contributor

There seems to be some concern to nested font sizing: 5f4d20c

But perhaps rem would be fine?

@andysellick
Copy link
Contributor Author

andysellick commented Aug 2, 2019

Interestingly on testing it seems rem is far less predictable than em. rem in the component guide produces one height but inside finder-frontend's search gives a much smaller height (actually creating the original issue in a different way). em produces a consistent height in both interfaces.

@andysellick
Copy link
Contributor Author

Looks like the reason for that is the body font size isn't set in the component guide (?) - we might need to look into that.

@NickColley
Copy link
Contributor

The main issue with 'em' and 'rem' when using it with the legacy GOV.UK Template is that GOV.UK Template messes with the root font size, which is likely what you're seeing.

@NickColley
Copy link
Contributor

We do have ways to only use relative units when compatibility mode is not turned on that we could consider.

@NickColley NickColley added the 🐛 bug Something isn't working the way it should (including incorrect wording in documentation) label Aug 2, 2019
@kellylee-gds kellylee-gds added accessibility Effort: days ⚠️ high priority Used by the team when triaging and removed awaiting triage Needs triaging by team labels Aug 7, 2019
@36degrees
Copy link
Contributor

It looks like this can affect text inputs, but only at extreme values (I had to modify the values for toolkit.zoomManager.zoomValues and zoom.maxPercent in Firefox's about:config to do this):

Screen Shot 2019-08-07 at 16 02 06

We'd probably also want to scale text inputs and buttons at the same time to ensure that they remain aligned – so I'm going to rename this to 'form inputs do not scale well…'.

@36degrees 36degrees changed the title Selects do not scale well if only font size increased Form elements do not scale well if only font size increased Aug 7, 2019
@36degrees 36degrees self-assigned this Sep 2, 2019
@hannalaakso hannalaakso assigned hannalaakso and unassigned 36degrees Sep 9, 2019
@hannalaakso
Copy link
Member

I did some investigation...

Requirement

WCAG 2.1 requires that user can resize text to at least 200% .

Inputs

Current behaviour

Chrome when text resized to 32 (16 x 2 = 200%)

Screen Shot 2019-09-12 at 14 57 32

Chrome when text resized to 48

Screen Shot 2019-09-12 at 14 58 15

Safari when text resized to 200%

Screen Shot 2019-09-12 at 14 59 36

Firefox when text resized to 200%

Screen Shot 2019-09-12 at 16 24 03

IE11 when text resized to Largest

Screen Shot 2019-09-12 at 16 29 36

Problem

We set the height of inputs with

height: 40px

which constraints them from expanding beyond that when text is resized.

Recommendation to fix

Swap the height property in text inputs to use min-height. This is to enable the element to expand when text size is increased. I tested setting min-height: 40px and saw no difference in supported browsers, apart from IE8 in which setting min-height makes the inputs taller than required; I haven't dug into this more but I think we could safely remove height from IE8, and wrap min-height in a conditional block which excludes IE8.

Selects

Current behaviour

Chrome when text resized to 32 (16 x 2 = 200%)

Screen Shot 2019-09-12 at 15 17 11

Chrome when text resized to 48

Screen Shot 2019-09-12 at 15 17 39

Safari when text resized to 200%

Screen Shot 2019-09-12 at 15 18 26

Firefox when text resized to 200%

Screen Shot 2019-09-12 at 16 25 31

IE11 when text resized to Largest

Screen Shot 2019-09-12 at 16 28 51

Problem

Again, we set the height of inputs with

height: 40px

which stops them from expanding beyond that when text is resized.

Recommendation to fix

This is a tricky one because setting min-height doesn't do anything on <select> elements. If we remove height, it allows the element to expand with the text size but the reduced height when using standard 16pt font is particularly noticeable in Chrome and Safari when compared against the current version of the element. Needs further discussion.

File inputs

Current behaviour

Chrome when text resized to 32 (16 x 2 = 200%)

Screen Shot 2019-09-12 at 16 20 27

Safari when text resized to 200%

Screen Shot 2019-09-12 at 16 22 16

Problem

This seems like a vendor issue with Chrome and Safari as the unstyled element has the same issue with overlapping text on larger font sizes.

px vs rem and compatibility mode

Chrome and IE fail to resize text when it's set in px. Our compatibility mode sets all font sizes in px to play nice with GOV.UK Template which only uses px sizing and sets global styles on <html>. We should maybe flag this about the compatibility mode and WCAG 2.1 requirement to resize text.

Other elements

I picked up on some related issues, raised here:
#1568
#1569

Reference: 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

@NickColley
Copy link
Contributor

NickColley commented Sep 12, 2019

@hannalaakso nice investigation, did you explore what happens if you use height with relative units? For example height: Nrem.

@andysellick
Copy link
Contributor Author

@hannalaakso excellent investigation. I did a fix for our select component on GOV.UK for this issue where height: 2.14em; (equivalent to 40px) worked.

@NickColley
Copy link
Contributor

@andysellick I think we'd need to avoid using em units as it is unpredictable depending on what their parent's font size, so we'd want to explore rem (but only outside compatibility mode).

@NickColley NickColley modified the milestone: Next Sep 16, 2019
@NickColley NickColley added the accessibility regulations failure Does not meet the Public Sector Accessibility Regulations (WCAG 2.2 level AA) label Oct 23, 2019
36degrees added a commit to alphagov/govuk_publishing_components that referenced this issue 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
accessibility regulations failure Does not meet the Public Sector Accessibility Regulations (WCAG 2.2 level AA) accessibility 🐛 bug Something isn't working the way it should (including incorrect wording in documentation) ⚠️ high priority Used by the team when triaging
Projects
Development

Successfully merging a pull request may close this issue.

5 participants