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 #2347

Merged
merged 3 commits into from
Sep 27, 2021

Conversation

hannalaakso
Copy link
Member

@hannalaakso hannalaakso commented Sep 14, 2021

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-2347 September 14, 2021 10:56 Inactive
src/govuk/components/panel/_index.scss Outdated Show resolved Hide resolved
src/govuk/components/panel/_index.scss Outdated Show resolved Hide resolved
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2347 September 16, 2021 18:11 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2347 September 23, 2021 12:30 Inactive
@hannalaakso hannalaakso marked this pull request as ready for review September 23, 2021 13:30
@hannalaakso hannalaakso changed the title Fix panel text being clipped when zooming on mobile Fix panel text overflowing on mobile Sep 23, 2021
hannalaakso added a commit that referenced this pull request Sep 23, 2021
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-2347 September 23, 2021 14:45 Inactive
Copy link
Contributor

@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.

Needs a changelog entry, but otherwise looks good to me! 👏🏻

@36degrees
Copy link
Contributor

Although I think the PR description needs updating now that we're no longer using hyphens: auto:

  • The wrapped words will also hyphenate using hyphens: auto which isn’t fully supported by Edge or by languages other than English (and it requires that the language of the document is set) but it is a progressive enhancement in this scenario to improve the experience if the browser and page language support it.

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.
@hannalaakso hannalaakso changed the title Fix panel text overflowing on mobile Fix panel text overflowing on mobile zoom Sep 27, 2021
@hannalaakso hannalaakso changed the title Fix panel text overflowing on mobile zoom 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-2347 September 27, 2021 09:26 Inactive
@hannalaakso hannalaakso merged commit 016d31f into main Sep 27, 2021
@hannalaakso hannalaakso deleted the fix-panel-text-resized branch September 27, 2021 09:29
@hannalaakso hannalaakso added this to the v3.14.0 milestone Sep 27, 2021
vanitabarrett pushed a commit that referenced this pull request Sep 27, 2021
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.
vanitabarrett pushed a commit that referenced this pull request Sep 28, 2021
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.
@EoinShaughnessy EoinShaughnessy changed the title Fix panel text overflowing when zoomed in on mobile Prevent panel text overflowing when zoomed in on mobile Sep 29, 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.

Text within panel component can overflow the container
3 participants