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

Enable-8 create a better character counter widget #144

Merged
merged 48 commits into from
Jul 11, 2024

Conversation

ocjadan
Copy link
Collaborator

@ocjadan ocjadan commented Jun 17, 2024

No description provided.

@ocjadan ocjadan added the component UX changing or adding to a components ux or creating ux of a new component label Jun 17, 2024
@ocjadan ocjadan self-assigned this Jun 17, 2024
@ocjadan ocjadan linked an issue Jun 17, 2024 that may be closed by this pull request
@alisonhall
Copy link
Collaborator

This page currently has the following text for the character count section:

The character counter uses a JavaScript library to implement it. Below is the HTML markup needed for it to work, as well as instructions on how to load the library in your own projects.

Are we still using a JavaScript library? If so, I think we should mention which library it is. If not, then this text needs to be changed.

content/body/textbox.php Show resolved Hide resolved
content/body/textbox.php Outdated Show resolved Hide resolved
content/body/textbox.php Outdated Show resolved Hide resolved
content/body/textbox.php Outdated Show resolved Hide resolved
content/body/textbox.php Outdated Show resolved Hide resolved
js/modules/enable-character-count.js Outdated Show resolved Hide resolved
js/modules/enable-character-count.js Outdated Show resolved Hide resolved
@ocjadan ocjadan closed this Jun 20, 2024
content/body/textbox.php Show resolved Hide resolved
content/body/textbox.php Show resolved Hide resolved
js/modules/enable-character-count.js Show resolved Hide resolved
@ocjadan
Copy link
Collaborator Author

ocjadan commented Jul 4, 2024

Hi @zoltan-dulac , I've decided on going with adding/removing an exclamation to the end of the text to force Chrome to "see a difference" on each key press.

For example:

  1. 1st key press = "Character Count: 10/100."
  2. 2nd key press = "Character Count: 10/100.!"
  3. 3rd key press = "Character Count: 10/100."

This approach works for Safari, Firefox and Chrome with VoiceOver on Mac.

@ocjadan
Copy link
Collaborator Author

ocjadan commented Jul 4, 2024

If you were wondering, here are other methods I've tried:

Did not work ❌:

  1. Adding or removing a whitespace at the end of the announcement text on each key press.
  2. Doing everything in the KeyUp event (removal, timeout, populate).

aria-atomic

  1. "true" without removing the <p> element.
  2. "true" while also deleting the <p> element and appending a new <p> element to live region each time.

aria-relevant

  1. Set to 'text'.
  2. Set to 'additions'.
  3. Set to 'additions removals' -> ⚠️ works but VoiceOver "double-speaks" — it tries to read out the removal and immediately is interrupted by the addition. Even with no timeout there is a noticeable interruption. As a result, don't think this is acceptable.

aria-live

  1. Set to 'assertive'.

aria-busy

  1. Setting to "true" on keydown and then "false" on key up (before or after .textContent).

Other Methods

  1. Force re-building between <p> and <div>.
  2. Force re-building between <p> and <span>.
  3. Repeating 9 and 10 with 'aria-atomic' as well.
  4. Using only <div> without the inner <p> element and changing .textContent for that single <div>.
  5. Removing the element around the text on every other keypress.
  6. Adding a brand-new <p> element within the ARIA live region on every key press.
  7. Remove the inner <p> element, use .textContent for <div> and appending to it on every key press. This sort of works but VoiceOver will repeat the entire string, which has the previous counts as well. ❌ Not acceptable.

width: 15rem;
float: left;
}
.enable-character-count {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we have a default style for the enable-character-counter and have it is part of the NPM package?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey @zoltan-dulac ,

Trying to understand your request a bit more, the <div< element that this style is applied to is programmatically added below the <textarea> — the <div> does not exist before the JavaScript is ran. As a result, I was wondering if you meant:

  1. Programmatically and explicitly setting the style, e.g. div.setAttribute("style", "border-color:#FFFFFF;");?
  2. enable-character-count.js should import less/textbox.less and apply the style programmatically?

@zoltan-dulac zoltan-dulac merged commit 5f61282 into main Jul 11, 2024
2 checks passed
@ocjadan ocjadan deleted the ENABLE-8-create-a-better-character-counter-widget branch July 12, 2024 15:30
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component UX changing or adding to a components ux or creating ux of a new component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a better character counter widget
3 participants