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

Change configuration API of CharacterCount #2888

Open
5 tasks
romaricpascal opened this issue Sep 29, 2022 · 0 comments
Open
5 tasks

Change configuration API of CharacterCount #2888

romaricpascal opened this issue Sep 29, 2022 · 0 comments
Labels
character count feature request User requests a new feature

Comments

@romaricpascal
Copy link
Member

What

Change the configuration options that the CharacterCount component accepts and:

  1. separate the limit from the type of what's counted ("words" or "characters"), instead of having maxwords and maxlength combining both limit and type and requiring that one takes precedence over the other

  2. clarify that the threshold is indeed a displayThreshold, not the character/words threshold

  3. I'll also throw in the mix to allow configuring the display threshold as a percentage or absolute value, but I'm not familiar as to why this is done via percentage at the moment. I find more natural to think "limit to 200 characters, warn starting at 150" rather than "limit to 200 characters, warn at 75%", but this may very well be personal and the decision to use percentage has probably stronger grounds than my feelings. This doesn't necessarily require two attributes as we could use:

  • if the threshold is < 1, treat it as a percentage
  • if it is >= 1, treat it as an absolute value

It's worth noting about 1 that the internals of the component kind of make that separation:

  • maxwords and maxlength get translated into a unique maxLength instance variable
  • the presence of config.maxwords is used in if similarly to checking if type == 'words'

As we introduce the new API, we'd deprecate the old one, which we'd remove in the next breaking release.
And we'll obviously need to document all that 😉

Why

Original idea was proposed by Ollie as part of this discussion when configuring the CharacterCount component via JS. While it didn't solve the issue at hand (having to override the JS config slightly differently for the component), it did seem like a good idea to the both of us, especially as it paves the route to fix #1364 (for 1).

Second and third point are smaller changes, but could add some clarity

Who needs to work on this

Developers, Technical writers

Who needs to review this

Developers, Technical writers

Done when

  • Decision on API is made
  • New API is implemented
  • Old API is deprecated
  • Documentation is updated to reflect the new API and deprecations
  • Issue is created to track removal of old API in next breaking release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
character count feature request User requests a new feature
Projects
None yet
Development

No branches or pull requests

2 participants