Suggestion for the "Characters Required" plugin

AI-generated summary

A discussion about improving the “Characters Required” plugin for Discourse. alltiagocom suggests adding character counting to the title and changing the text from “N characters required” to “N characters left” for better user feedback. merefield responds that a Theme Component already exists to achieve this, making the plugin unnecessary, as Theme Components didn’t exist when the plugin was created. Canapin questions why the official solution is a plugin instead of a Theme Component, and merefield clarifies that Theme Components weren’t available at the time. alltiagocom shares a modified version of the Theme Component with changes to text color and display (e.g., “0 of N required”), noting it feels less intrusive. merefield encourages forking and modifying the component, emphasizing compactness and language independence. alltiagocom expresses unfamiliarity with GitHub but appreciates the tool. A bug is reported where spaces at the end of text aren’t counted in the character display, though merefield explains this is intentional as Discourse trims trailing spaces. alltiagocom acknowledges the behavior is confusing but accepts it, praising the tool’s usefulness.

I just installed the plugin from GitHub - discourse/discourse-characters-required: Display how many characters are required before a post be made · GitHub and I have 2 requests that I believe would make the plugin a bit better:

1 - Adding the same feature to the title would be valuable as well. Showing that there’s also a minimum number of characters there is a must.
2 - Once the user starts typing, the text could change from N characters required to N characters left (or remaining). Then if the person deletes the text again, it goes back to required. This one is just a small tweak to make the feature more consistent to what’s happening at a given moment. Not a “must”, just a tweak.

4 Likes

Way ahead of you. :wink:

If my component survives the new composer update I will make a dedicated topic for it.

Note that it is a Theme Component. Please star it on GitHub :star:

4 Likes

Do you know why the official solution is a plugin instead of a theme component? What does it need that requires it to be a plugin?

1 Like

My Theme Component makes the plugin completely unnecessary. The plugin is quite old and predates the Theme Components. It wasn’t an option when it was built.

1 Like

I understand that, I’m just wondering why Discourse didn’t make it a TC instead of a plugin :person_shrugging:

Because Theme Components didn’t exist back then. They weren’t an option.

3 Likes

Where were you a few hours go to prevent me from having to go through the painful process of installing the plugin? :wink:

That is indeed what I wanted.

A few suggestions, if you think they are worth implementing:
1 - Ability to change the color of the text. In my particular case, I like it in the original color. On my non-professional UI expertise, I like to see red only when something is over the limit, for example, too many characters that will throw an error if I try to save, or if it doesn’t follow a specific format (e.g. a URL, an email, etc). The red for me here automatically looks “weird”, because it’s almost as if something is already wrong, even before I did anything.
2 - Showing something like “0/15” kinda feels like: “you haven’t typed anything on your limit of just 15 characters”. I know that people eventually understand what that means, but I always like to have everything as clear as possible, even for people who know what that means. So in this case, offering a few different options would be great, one of them being 0 of N required.

I downloaded the ZIP from GitHub and made those modifications for myself and now it looks like this:

It just feels less intrusive for me and more self-explanatory, without taking too much space. What do you think?

1 Like

Feel free to fork and amend. I don’t intend to put any additional effort into it except to keep it working.

I specifically left out any words so it is instantly comprehensible in all languages.

It’s also important to keep the presentation as compact as possible so keeps out of the way of the users text as much as possible.

1 Like

I’m not very familiar with GitHub and all that. I just make small changes to things I know and in this case ChatGPT helped, but GitHub is a completely foreign world…

I think this isn’t an issue, especially because I will have it to remove the text once it meets the requirement.

Even with spaces:
image

One “bug” I noticed though is that when using SPACE it doesn’t show in the count, even though it counts it.
So A counts as 2, but the text only shows 1 of 15 instead of 2 of 15

2 Likes

Oh thanks for the report. I will look at that.

2 Likes

Ah it trims the ends of the text of spaces. Which is what Discourse does (spaces at either end don’t count and won’t be saved). You will notice it catches up once you type another character which is not a space. So I believe the current implementation is correct.

2 Likes

Yes, I noticed that when I typed another character it would catch up. Still weird that this is the behavior, because if a space is counted as a character, then it should be visible, otherwise if it shows 13 and the limit is 15, that means I have 2 more characters, but then it jumps from 13 to 15 (in my case it will hide the count). All because there’s a space at the end. It can be a bit confusing for the users.

But if it’s something you can’t change, then I guess “it is what it is” :wink:
This is already a useful tool, regardless. :raising_hands: Thanks