- Issue created by @Sapnakhatri
- Merge request !8Issue #3440466: Implement Word Count Feature for text, textarea and ckeditor5 fields in textfield_counter Module. โ (Open) created by Sapnakhatri
- Issue was unassigned.
- Status changed to Needs review
about 1 year ago 5:42am 23 April 2024 - Status changed to RTBC
12 months ago 6:20am 9 June 2024 - ๐ฎ๐ณIndia adwivedi008
Test the MR-8 changes with CKE-5 and Drupal-10 and its working fine as the feature is expected
Moving the issue to RTBC
- Status changed to Needs work
10 months ago 12:24pm 22 August 2024 - ๐ฌ๐งUnited Kingdom hocu London
This one has one small bug, though. The counter works fine for words, while entering text. But as soon as you clear the field, "Used" value is still 1, see the screenshots.
The issue is around:
var rawInput = $("<div/>").html($(this).val()); input = rawInput.text().trim().replace(/(\r?\n|\r)+/g, " "); var words = input.split(" "); currentLength = words.length;
When you split an empty string, you get an array with one empty string. So,
var words = input.split(" ")
returns[""]
. Therefore, the length is 1.The solution is simple though, we just need a check for
rawInput.text()
, and if it's not empty, we can proceed to sanitise its input and split it.I'll submit a patch for that one today.
- Assigned to hocu
- Issue was unassigned.
- Status changed to Needs review
10 months ago 12:58pm 22 August 2024 - Status changed to RTBC
9 months ago 1:03pm 27 August 2024 Hello,
I have tested this feature on my local. It looks good to me. Attaching screenshot for reference. Moving this to RTBC.
- Status changed to Needs review
9 months ago 1:06pm 27 August 2024 - Status changed to RTBC
9 months ago 1:07pm 27 August 2024 - ๐ซ๐ทFrance mably
This issue's MR needs to be rebased against 2.x. Thanks.
- ๐ฌ๐งUnited Kingdom hocu London
@mably, I don't think it is a straightforward rebase now, is it? It looks like the 2.x branch uses vanilla JavaScript now, whereas this work was based on the code that used jQuery.
I am marking this as โneeds workโ.
- ๐ซ๐ทFrance mably
Yep, the MR must be slightly updated to work without jQuery but it shouldn't be too difficult.
- ๐ฌ๐งUnited Kingdom hocu London
I plan to work on it this weekend, unless someone else takes it up first.