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

Prevent panel text overflowing when zoomed in on mobile #2366

Merged
merged 3 commits into from
Sep 28, 2021

Conversation

vanitabarrett
Copy link
Contributor

@vanitabarrett vanitabarrett commented Sep 27, 2021

Note: this PR cherry-picks commits from #2347 in order to merge and release them from a support branch. Ordinarily, this fix would be made in the support branch first, and then copied over to main. However, in this instance, we're testing out the support branch release process in a slightly artificial scenario - the change has already been made (unreleased) in main, but we want to trial out releasing it from the support/v3.x branch

As discussed in #2173, the panel heading text can overflow its container when a user increases text size on a mobile eg. using iOS Safari text resize controls. The overflowing is a particular problem with the panel component since it uses white text. When the text overflows the container, it is invisible on the white (page) background. When the text in our other components overflow, the user might have to scroll horizontally to view it but the the text remains legible.

We should aim to meet the WCAG Text resize Success criterion which requires that

text can be scaled up to 200%

How we fix this

To help fix this, this PR:

  • Decreases the padding of the panel component on mobile to allow the text flow better.
  • As an if-all-else-fails attempt to stop very long words from overflowing, forces them to break and wrap instead. Hopefully this is not something that would happen often since we now also reduce the padding to help with this.

Possible future improvements

We additionally considered reducing the font size of the heading on a mobile to avoid the text wrapping at very narrow viewports. However, the govuk-font mixin uses the responsive font size map which fixes font sizes for different breakpoints to make our components behave consistently. There currently isn’t a way to override those set font sizes for govuk-font. Since the other fixes in this commit go a long way towards solving this issue and we haven’t come across this requirement with our other components so far, we’re hesitant to add this new feature to govuk-font at this point, but we’ll keep an eye out for similar requirements in the future.

We could consider adding something to the panel guidance about the need to keep the panel heading wording concise.

iOS 12 mini in Safari at 100% (no zoom)

Before

Screenshot 2021-09-14 at 11 34 26

After

Screenshot 2021-09-23 at 13 35 17

iOS 12 mini at 150% zoom

Before

Screenshot 2021-09-14 at 11 34 47

After

Screenshot 2021-09-23 at 15 33 46

iOS 12 mini at 200% zoom

Before

Screenshot 2021-09-14 at 11 37 39

After

Screenshot 2021-09-23 at 15 34 01

We decided not to hyphenate words that wrap

We also considered progressively enhancing any words that wrap by using hyphens: auto to hyphenate them but this seemed to potentially introduce more problems than it was solving. For instance, we found that iOS Safari can omit the dash from some words but not others, see below:

Screenshot 2021-09-23 at 15 52 48

iOS Safari can also hyphenate words unnecessarily, see below:
Screenshot 2021-09-23 at 15 53 36

Fixes #2173

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2366 September 27, 2021 14:55 Inactive
@vanitabarrett vanitabarrett changed the title Support branch: Fix panel text overflowing when zoomed in on mobile Fix panel text overflowing when zoomed in on mobile Sep 27, 2021
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2366 September 27, 2021 14:56 Inactive
@vanitabarrett vanitabarrett marked this pull request as ready for review September 27, 2021 15:15
hannalaakso and others added 3 commits September 28, 2021 11:31
What the problem is

Prevent text in the panel component from overflowing on mobile zoom. This overflowing is more likely to happen when user increases text size on a mobile eg. using iOS Safari text resize controls. The overflowing is a particular problem with the panel component since it uses white text. When the text overflows the container, it is invisible on the white (page) background. When the text in our other components overflow, the user might have to scroll horizontally to view it but the the text remains legible.

We should aim to meet the WCAG Text resize Success criterion which requires that text can be scaled up to 200%.

How this fixes it

Decrease the padding on mobile to allow the text flow better.

As an if-all-else-fails attempt to stop very long words from clipping, force them to break and wrap instead. Hopefully this is not something that would happen often since we’re reducing the padding to help with this.

We additionally considered reducing the font size of the heading on a mobile to avoid the text wrapping at very narrow viewports. However, the `govuk-font` mixin uses the responsive font scale which fixes font sizes for different breakpoints to make components behave consistently. There currently isn’t a way to override those set font sizes for `govuk-font`. Since the other fixes in this commit go a long way towards solving this issue and we haven’t come across this requirement with our other components so far, we’re hesitant to add such new feature to `govuk-font` at this point, but we’ll keep an eye out for similar requirements in the future.

We also considered progressively enhancing any words that wrap by using `hyphens: auto` to hyphenate them. However, we found that iOS Safari can omit the dash from some words but not others, or hyphenating unnecessarily; it seems that it would be introducing more issues than it would be solving. See #2347 for more details.
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2366 September 28, 2021 10:32 Inactive
@vanitabarrett vanitabarrett merged commit 23c6309 into support/3.x Sep 28, 2021
@vanitabarrett vanitabarrett deleted the fix-panel-overflow branch September 28, 2021 10:35
@36degrees 36degrees changed the title Fix panel text overflowing when zoomed in on mobile Prevent panel text overflowing when zoomed in on mobile Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants