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

Preserve the state of character count when navigating 'back' #1868

Merged
merged 2 commits into from
Jul 16, 2020

Conversation

vanitabarrett
Copy link
Contributor

@vanitabarrett vanitabarrett commented Jul 16, 2020

Fixes #1848

What

When the user navigates back to a previous page that includes a character count, the character count message should reflect the text currently in the textarea.

Why

Fix based on #1842
Previously, when navigating back to a page with a character count, the character count message wouldn't update (reflect the text currently in the textarea) until the textarea received focus.

Current behaviour: http://govuk-frontend-review.herokuapp.com/full-page-examples/feedback
Preview new behaviour: https://govuk-frontend-review-pr-1868.herokuapp.com/full-page-examples/feedback

Notes

On slow connections there may be a flash of the default character count text before it updates. From testing with a 4x CPU slowdown, the default text may show for 0.03s before it updates. Given how small this is even with slowdown, we've decided to leave it as-is. If we decide this is an issue in the future, we'd also need to look at other components (e.g: radios and checkboxes) which are affected in a similar way.

Browser testing

  • IE8 (Windows)
  • IE9 (Windows)
  • IE10 (Windows)
  • IE11 (Windows)
  • Edge (Windows)
  • Chrome (Windows)
  • Firefox (Windows)
  • Safari (macOS)
  • Chrome (macOS)
  • Firefox (macOS)
  • Safari (iOS)
  • Chrome (iOS)
  • Chrome (Android)
  • Samsung Internet (Android)

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1868 July 16, 2020 10:45 Inactive
@vanitabarrett vanitabarrett marked this pull request as ready for review July 16, 2020 10:50
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1868 July 16, 2020 11:26 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.

Minor question about the naming of the function that might be worth thinking about, but this looks good to me 👍

src/govuk/components/character-count/character-count.js Outdated Show resolved Hide resolved
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1868 July 16, 2020 15:20 Inactive
this.sync()
}

CharacterCount.prototype.sync = function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1868 July 16, 2020 15:32 Inactive
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.

Character count can show incorrect count when going 'back', or if page is discarded and restored
3 participants