-
Notifications
You must be signed in to change notification settings - Fork 19
Character count for titles and summary fields #537
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
Comments
Textfield Counter may be worth investigating. |
Deploy to Product |
@willguv This has been deployed to the product site. I have enabled it on the title and body fields on service pages. It doesn't seem to handle body summaries though. |
Thanks @stephen-cox
Maxlength: 160 Twitter has nice UX (about the only thing it does have these days) |
@willguv I've taken another look and managed to enable the word count on the summary and disabled it on the body. It's possible to edit the text and insert any HTML we like; there are placeholders for |
Hi @stephen-cox, so presumably we could show something like @currentlength/ @maxlength eg 18/ 160 Is it possible to show if a user has exceeded the max length? I was thinking something like 190/ 180 with a color change |
@willguv certainly possible to do something like The Textfield Conter module doesn't include any JS to change colour and certainly not like the Twitter example where text over a certain limit is highlighted. This should be possible, but would likely need to be a CKEditor plugin which we can then wrap in a Drupal module. |
Thanks @stephen-cox I'm assuming summary is a Drupal field rather than CK Editor - is that right? Presumably this gives us more control of it On the CKEditor front, could we use https://ckeditor.com/docs/ckeditor5/latest/features/word-count.html |
Be careful of that text_counter module. We found that it breaks if there's a boolean field on your page. https://www.drupal.org/project/textfield_counter/issues/3377415 |
@willguv Summaries are plain textarea fields which would make it easier to alert the contents with JavaScript. If highlighting text is something we want then it would be worth reviewing the Textfield Counter module to see if it's worth extending it to highlight text or whether this would be too much trouble and we're better off creating our own module for this. In either case this will be non-trivial. @markconroy thanks for the heads-up on that issue - if we go ahead with this I'll keep that under review |
The Thunder distribution uses this module https://www.drupal.org/project/length_indicator which has worked well on other projects too. It is nice because it is more of a visual indicator rather than hard limits. |
Thanks @finnlewis think that's much nicer. @stephen-cox could you remove textfield counter please and install this instead When I'm up and running I'll be able to stop asking you to install things for me :) |
Hi @willguv, I have installed and enabled the Length Indicator module on the product site and configured it for Service Pages. From the README:
This means it only works for titles and not bodies or summaries. For titles it looks like: |
Option for a council to set a hard limit (ie not save) on specific fields? |
Hi @stephen-cox had a quick go with Length Indicator and it's not immediately clear what it's doing I think we're better off with Textfield Counter with some hopefully minor mods Instead of Maxlength: 160 Could we show 105 ie the remaining number, and change its color as it gets closer to the limit
We could explore styling text in CKEditor at a later date |
What's the label? |
@willguv I've added the Textfield Counter module back to the product site and configured the title and summary to use this. There is some colour feedback on this. The numbers go orange close to the limit: and red after the limit: The colours and the stage when they change don't look configurable, but I can investigate into how easy it is to change this or submit a patch to the module to make this configurable. We can change the text, but from an accessibility point of view we need to provide a textual description of what the numbers refer to. |
Hi @stephen-cox this looks really promising Could we:
Is it possible to switch the order of "Characters" and the number around ie "-6 characters" Does that work from an accessibility point of view? |
Set up new installs to use this with an on/ off switch Existing councils would need documentation |
Hi @stephen-cox this sounds ideal. How much effort please? |
@willguv It's not small, but less than a days work. A remaining question is where should it live. Do we want to include this as part of core or should it be it's own module (either a a submodule of core or something stand alone). My instinct is to create this as part of core and then if we decide it's better on it's own it can be split out easily enough. |
PB 30 Jan 2025
|
@willguv I've started prototyping the form that to turn on and off character counting. What are your thoughts on the following screenshot? It allows a user to select the title and summary lengths and the fields for each LocalGoc Drupal content type it should be applied to |
Hi @stephen-cox I can see how this would allow a content designer to specify number of characters for title and summary, and the fields to apply it to I'm not sure how the following would work:
We could catch up on a call if easier? |
Hi again @stephen-cox I was thinking about how this is likely to be used. Content designers need to:
I don't think we need to show all of this underneath the title and summary fields Remaining isn't needed, rather an indication of how close you are to max length So how about this? @currentlength/ @maxlength characters eg 18/ 160 characters |
I don't think this form would ever be accessible by a content designer. It will make a l 9E88 ot of configuration changes which, if being managed through version control as is best practise, will need to be exported after being saved. This makes it a Drupal admin function. All the config in this form can be applied already, it just has to be done to each field. That means if there are exceptions they can be done at the field level; making this form much simpler. Otherwise we're going to spend lots of time replicating functionality that can already be done in a slightly different way. Happy to discuss. |
Hi @stephen-cox I think I understand better now Is there a way for an admin to apply specific title and summary values to a set of fields, and different title and summary values to another set of fields? Or is this "apply these values to these fields only"? If it's the latter I think that's fine. That will be a big help to councils and the core need here. |
Add a field to configure the message, starting with this default @currentlength/ @maxlength characters eg 18/ 160 characters |
Hi @stephen-cox am keen to progress this before Thursday if possible |
@willguv Just to update you on this, I have the form working to add and remove character counting the title and summary fields. There's a draft PR for this here: localgovdrupal/localgov_core#278 It needs some further testing and some automated test written for it before it's ready for review. |
We decided to create a localgov_utilities module and put this there. Work in progress at https://www.drupal.org/project/localgov_utilities |
|
There's now a utilities module on drupal.org that contains this work and there's a PR to include the utilities module in the profile here: #846 The README for the Character Counting module includes some docs: https://git.drupalcode.org/project/localgov_utilities/-/tree/1.x/modules/localgov_char_count?ref_type=heads |
Thanks @stephen-cox, let's try to get this reviewed so I can include in 24th April newsletter. Appreciate your hard work on this!! |
Uh oh!
There was an error while loading. Please reload this page.
This was raised at the content <> backlog get together on 25th April
Some content designers would like support to write SEO length summaries
Titles weren't mentioned but we should consider this. Evidence suggests a character count of 55-70
Let's discuss at the Backlog Group
The text was updated successfully, but these errors were encountered: