8000 Character count for titles and summary fields · Issue #537 · localgovdrupal/localgov · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Closed
willguv opened this issue Apr 25, 2023 · 39 comments · Fixed by #846
Closed

Character count for titles and summary fields #537

willguv opened this issue Apr 25, 2023 · 39 comments · Fixed by #846
Assignees
Labels

Comments

@willguv
Copy link
Member
willguv commented Apr 25, 2023

This was raised at the content <> backlog get together on 25th April

Some content designers would like support to write SEO length summaries

  • Googling suggests a character count of 155-160
  • Siteimprove suggests 110

Titles weren't mentioned but we should consider this. Evidence suggests a character count of 55-70

Let's discuss at the Backlog Group

@willguv willguv converted this from a draft issue Apr 25, 2023
@andybroomfield
Copy link
Contributor

Textfield Counter may be worth investigating.

@willguv
Copy link
Member Author
willguv commented Aug 30, 2023

Deploy to Product

@willguv willguv moved this from Refine to Ready in 2025 Refresh/ Editor experience Aug 30, 2023
@willguv willguv moved this from Ready to In Progress in 2025 Refresh/ Editor experience Aug 30, 2023
@stephen-cox
Copy link
Member

@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.

@willguv
Copy link
Member Author
willguv commented Sep 4, 2023

Thanks @stephen-cox

  • we won't need to show this on body fields
  • any reason why it can't be shown on body summaries? Aside from title, that was the field that content designers were most interested in
  • can we style the message in some way? This is what it shows now:

Maxlength: 160
Used: 55
Remaining: 105

Twitter has nice UX (about the only thing it does have these days)

Image
Image

@stephen-cox
Copy link
Member

@willguv I've taken another look and managed to enable the word count on the summary and disabled it on the body.

image

It's possible to edit the text and insert any HTML we like; there are placeholders for @maxlength, @current_length and @remaining_count.

@willguv
Copy link
Member Author
willguv commented Sep 5, 2023

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

@stephen-cox
Copy link
Member

@willguv certainly possible to do something like @currentlength/@maxlength

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.

@willguv
Copy link
Member Author
willguv commented Oct 3, 2023

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

@markconroy
Copy link
Member

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

@stephen-cox
Copy link
Member

@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

@finnlewis
Copy link
Member

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.

@willguv
Copy link
Member Author
willguv commented Oct 21, 2023

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 :)

@stephen-cox
Copy link
Member
stephen-cox commented Nov 30, 2023

Hi @willguv, I have installed and enabled the Length Indicator module on the product site and configured it for Service Pages.

From the README:

Please note: Currently string_textarea ("Text area (multiple rows)") and string_textfield
("Textfield") are the only supported field widgets.

This means it only works for titles and not bodies or summaries. For titles it looks like:

image

@willguv
Copy link
Member Author
willguv commented Jan 9, 2024

Option for a council to set a hard limit (ie not save) on specific fields?

@willguv
Copy link
Member Author
willguv commented Jan 16, 2024

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
Used: 55
Remaining: 105

Could we show

105

ie the remaining number, and change its color as it gets closer to the limit

  • Orange up to the limit
  • Red when we fall over to minus numbers (are these provided for in Textfield Counter?)

We could explore styling text in CKEditor at a later date

@willguv
Copy link
Member Author
willguv commented Jan 24, 2024

What's the label?
Can we style the number?

@stephen-cox
Copy link
Member

@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:

image

and red after the limit:

image

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.

@willguv
Copy link
Member Author
willguv commented Feb 7, 2024

Hi @stephen-cox this looks really promising

Could we:

  • drop max length and used
  • change 'Remaining' to "Characters"

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?

@willguv
Copy link
Member Author
willguv commented Feb 14, 2024

Set up new installs to use this with an on/ off switch

Existing councils would need documentation

@willguv willguv moved this from In Progress - Core team to Not doing in 2025 Refresh/ Editor experience Mar 28, 2024
@willguv willguv moved this from Not doing to Ready in 2025 Refresh/ Editor experience May 8, 2024
@willguv
Copy link
Member Author
willguv commented Dec 18, 2024

I was thinking of a form that allows a user to set the size of a title and summary and when applied configures this for LGD content types with text and summary fields. The form could also allow a user to select which LGD content types they want to apply this too. How does this sound?

Hi @stephen-cox this sounds ideal. How much effort please?

@stephen-cox
Copy link
Member

@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.

@willguv willguv removed the Started label Dec 19, 2024
@willguv
Copy link
Member Author
willguv commented Jan 30, 2025

PB 30 Jan 2025

  • provide a form where content designers can set character lengths for title and summary
  • process applies this to all LGD content types
  • include the ability to turn off

@stephen-cox
Copy link
Member

@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

Image

6D40
stephen-cox added a commit to localgovdrupal/localgov_core that referenced this issue Feb 3, 2025
@willguv
Copy link
Member Author
willguv commented Feb 3, 2025

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:

  • if they've applied different character lengths to some fields. Is a set given a name, and then you see a list of sets?
  • if they want to remove some of the settings

We could catch up on a call if easier?

@willguv
Copy link
Member Author
willguv commented Feb 4, 2025

Hi again @stephen-cox I was thinking about how this is likely to be used. Content designers need to:

  • set default values for title and summary fields
  • add exceptions (click on "add exception", enter different values for title and summary fields, select the fields to which these values apply)
  • see a list of exceptions, and edit/ delete them

I don't think we need to show all of this underneath the title and summary fields

Image

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

@stephen-cox
Copy link
Member

Content designers need to:

* set default values for title and summary fields
* add exceptions (click on "add exception", enter different values for title and summary fields, select the fields to which these values apply)
* see a list of exceptions, and edit/ delete them

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.

@willguv
Copy link
Member Author
willguv commented Feb 4, 2025

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.

@willguv
Copy link
Member Author
willguv commented Feb 13, 2025

Add a field to configure the message, starting with this default

@currentlength/ @maxlength characters

eg 18/ 160 characters

@willguv
Copy link
Member Author
willguv commented Feb 25, 2025

Hi @stephen-cox am keen to progress this before Thursday if possible

@willguv willguv moved this to In Progress - Core team in 2025 Priorities Feb 27, 2025
@willguv willguv moved this from In Progress - Core team to In Progress - Everyone else in 2025 Priorities Mar 13, 2025
@willguv willguv moved this from In Progress - Everyone else to In Progress - Core team in 2025 Priorities Mar 13, 2025
@stephen-cox
F438
Copy link
Member

@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.

@finnlewis
Copy link
Member

We decided to create a localgov_utilities module and put this there.

Work in progress at https://www.drupal.org/project/localgov_utilities

@willguv
Copy link
Member Author
willguv commented Apr 3, 2025
  • move to drupal.org
  • provide read me
  • @willguv to check on product site and write docs
  • enable on demo site

@stephen-cox
Copy link
Member

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

@willguv
Copy link
Member Author
willguv commented Apr 9, 2025

Thanks @stephen-cox, let's try to get this reviewed so I can include in 24th April newsletter. Appreciate your hard work on this!!

@github-project-automation github-project-automation bot moved this from In Progress - Core team to Done in 2025 Priorities Apr 15, 2025
@github-project-automation github-project-automation bot moved this from In Progress - Core team to Done in 2025 Refresh/ Editor experience Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Status: Done
6 participants
0