Problem/Motivation

It is unnecessary work for a site builder to check the Safe truncate html option for every formatted text field in order to get a character count. Instead, that should happen for all formatted text fields.

Screenshot of Safe truncate html setting

Proposed resolution

In the code, detect whether a field uses formatted text. If so, skip HTML markup in the character count.

Remaining tasks

  1. Discuss pros and cons to this proposal
  2. Make final decision
  3. Write patch
  4. Test patch
  5. Deploy

User interface changes

Remove the Safe truncate html option from the interface.

CommentFileSizeAuthor
#3 maxlength-safe-truncate-html.png51.97 KBcedewey

Issue fork maxlength-3230544

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

cedewey created an issue. See original summary.

cedewey’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
cedewey’s picture

Issue summary: View changes
StatusFileSize
new51.97 KB
cedewey’s picture

Title: Ignore html markup in character count by default » Apply safe truncate HTML behavior by default on rich text fields
cedewey’s picture

We invite Drupal users to participate in our poll about this

Drupal Slack - https://drupal.slack.com/archives/C1AFW2ZPD/p1642796032021600

Fediverse (eg: Mastodon) - https://social.coop/web/statuses/107662309391153132

Twitter - https://twitter.com/claybolto/status/1484623479592861697

cedewey’s picture

cedewey’s picture

Issue summary: View changes

No one participated in either of the three polls so we're interpreting that as people are ok doing away with this configuration setting and assuming people want HTML tags ignored in the character count.

boehmrya’s picture

Assigned: Unassigned » boehmrya

Just to add my thoughts - I agree with doing away with this configuration. I know that my impression was always that the maxlength setting should apply strictly to characters, and not include html. I imagine most people would interpret the setting in a similar way.

The one situation (that I can think of) where this may be confusing is when you have a formatted text field (as opposed to a long text field), where the html is clearly visible in the form (no wysiwyg editor). So, it may be worth adding some help text clarifying that the maxlength setting does not count html tags in formatted text fields.

I'll assign this task to myself, and work on a patch.

boehmrya’s picture

Assigned: boehmrya » Unassigned

Sorry - I haven't had as much time to work on this recently, so i'm going to unassign it from myself.

hipp2bsquare’s picture

Assigned: Unassigned » hipp2bsquare

I'll take this on as my next task.

hipp2bsquare’s picture

Assigned: hipp2bsquare » cedewey
Status: Active » Needs review

Clayton -- I've put in a merge request for my work automatically performing safe truncate on all HTML fields (see above). Please test for usability/bugs, then turn over to Steven for code review.

  • cedewey committed 6740bfd on 2.0.x authored by hipp2bsquare
    Issue #3230544 by hipp2bsquare, cedewey, boehmrya: Apply safe truncate...
cedewey’s picture

Assigned: cedewey » srdtwc

I've tested this and works as expected from an editing perspective. Assigning to Steven for code review.

srdtwc’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.