alphagov / govuk-design-system-backlog

GOV.UK Design System Community Backlog
31 stars 2 forks source link

Character count #67

Open govuk-design-system opened 6 years ago

govuk-design-system commented 6 years ago

Use this issue to discuss the character count component.

querkmachine commented 1 year ago

This mismatch is, basically, the result of a difference in the specifications for HTML and HTTP.    In the current specification for HTML, new lines within a textarea are represented by a single code point, LF (line feed), aka POSIX/Unix style, \n, or U+000A.   However, in the specification for HTTP, new lines are represented as two code points, CR (carriage return) and LF (line feed), aka Windows style, \r\n, or U+000D U+000A.   This is why one code point on the front-end becomes two on the back-end. It's basically 'transformed' in the HTTP transmission process.

As our component only counts code points, and HTML/JS will only ever see one code point, we will always have a mismatch between what we have and what the backend actually receives when it comes to new lines.

I don't think the solution is to change the character count component, however.

This does, unfortunately, leave the onus of how to validate all of this on the backend.

As an interim solution for new lines specifically, it might be possible to detect and remove the carriage return characters from the received value before performing length validation. This would no longer suffice if we move to grapheme-based counting, however.

frankieroberto commented 1 year ago

Our service has a "personal statement" section where candidates have to write a longish (up to 600 words) statement about why they'd make a good teacher.

We use the Character count component for this (but set to a word limit not a character limit).

However we are noticing that quite a lot of users still submit the form with the personal statement over the word limit.

Our assumptions are that one (or both) or the following might be the cause:

We’re currently exploring ways to potentially mitigate this.

stevenjmesser commented 1 year ago

Sounds good, @frankieroberto, let us know what you find!

andythenorth commented 1 year ago

Hi (also hi @stevenjmesser ) we're not Design System users here at Delib, but we use it as reference for Citizen Space UI.

We have recently run into the same issues with character counts, and have had a crash course in graphemes. Watching with interest.

L-e-a-n-n-e-H commented 1 year ago

We’ve come across an issue whereby when someone types into the text area box if there is a delay of about 1 second before they type another character in, the screen reader will read out the remaining character count, this continues to happen for the entire sentence they are writing. This can be a bit excessive for people who do not type or can type quickly and use a screen reader. Has anyone set the character count to more than 1 second, is this achievable? Or does anyone know of an optimal length of time before the character count starts to read out on a screen reader? Thank you :)

dav-idc commented 1 year ago

Hi @L-e-a-n-n-e-H, thanks for providing this feedback! I have a couple clarifying questions on the specific scenario, if you're able to provide more info. It's alright if you don't have answers for all the questions though. 👍

L-e-a-n-n-e-H commented 1 year ago

Hi @davidc-gds , many thanks for the quick reply, much appreciated!

Thank you!

characters remaining

CharlotteDowns commented 1 year ago

We ran an external accessibility audit for some of the components and patterns in GOV.UK Frontend in May 2023. In that audit, we included an example of the Character count component. We’re adding results from that audit here so that we can:

One usability accessibility issue raised

The hidden character count only pops up when you approach threshold is strange usability-wise.

The character count for the text area ‘What were you trying to do?’ does not appear until the user reaches fifty characters. It can be beneficial to display this from the start and the max characters to allow users to understand this restriction before entering data. This means that when the user reaches 50 characters, and are made aware, they then do not have to amend what they have already entered in order to not exceed the 100 limit.

More detail in this issue:

joelanman commented 1 year ago

Just to note the threshold is an optional feature. We designed it with the aim that most fields would be large enough to accept most input, and not make the user have to think about the character/word limit. In the minority case where users might hit the limit, the threshold option allows those users to know they are near the limit.