I'd file this issue as a feature request, but we are past that threshold for D8 and this is one of those trivial things that I'd like to see fixed. So, a bug it is...

As it is now, the "Trim length: 600" is confusing to newcomers. "Is it characters or words?" that's the most often-asked question I get from people when I show them that part of the UI. How about we fix it by simply adding a "characters" text so to clarify what we are actually referring to?

display

configure

CommentFileSizeAuthor
#71 trimmed_2.png58.5 KBdani3lr0se
#71 trimmed_1.png46.79 KBdani3lr0se
#69 1862250-trim_field_description-67.patch1.28 KBNovitsh
#66 1862250-trim_field_description-66.patch1.28 KBNovitsh
#60 d7_field_description.png43.34 KBsdstyles
#60 interdiff-57-60.txt674 bytessdstyles
#60 1862250-trim_field_description-60.patch1.32 KBsdstyles
#58 1862250-trim_field_description-57.jpg114.25 KBHeimdallJHM
#57 1862250-trim_field_description-57.patch1.23 KBNovitsh
#46 1862250-46-patch-expanded.jpg21.7 KBamanire
#46 1862250-trim-field-description-46.patch1.4 KBamanire
#46 1862250-46-patch-collapsed.jpg9.39 KBamanire
#43 1862250-trim-field-description-43.patch1.51 KBamanire
#43 1862250-43-patch-expanded.jpg20.81 KBamanire
#43 1862250-43-patch-collapsed.jpg9.1 KBamanire
#41 1862250-trim-field-description-41.patch1.5 KBamanire
#41 1862250-41-patch-expanded.png66.18 KBamanire
#39 1862250_issue_verification.png21.62 KBcluther
#38 1862250-trim-field-description-38.patch1.38 KBamanire
#36 1862250-36-patch-collapsed.jpg8.83 KBamanire
#36 1862250-36-patch-expanded.jpg18.54 KBamanire
#36 1862250-36-expanded.jpg19.29 KBamanire
#36 1862250-36-collapsed.jpg8.47 KBamanire
#36 1862250-trim-field-description-36.patch1.37 KBamanire
#32 1862250-31-preview-expanded.jpg34.9 KBdahousecat
#32 1862250-31-preview-collapsed.jpg20.32 KBdahousecat
#31 1862250-31.patch1.27 KBrpayanm
#27 Trim-lenght-description-186250-27.patch1.25 KByoroy
#27 1862250-trim-length.jpg72.44 KByoroy
#26 interdiff-1862250-26.txt953 bytesjoshi.rohit100
#26 trim-field-description-1862250-26.patch886 bytesjoshi.rohit100
#25 trim-field-description-1862250-25.patch892 bytesacabouet
#20 1862250-suffix-screenshot-eww.png21.43 KBjoates
#20 1862250-trim-breakpoint-screenshot.png22.52 KBjoates
#18 1862250-18-screenshot.png47.97 KBjoates
#18 drupalcore-trim-field-description-1862250-18.patch774 bytesjoates
#16 field_ui_details-1862250-16.patch1.26 KBIvan Zugec
#11 1862250-trim-unit-screenshot.png87.79 KBjoates
#10 trimmed_chars_configure.png62.03 KBvineet.osscube
#8 field_ui_details-1862250-8.patch1.21 KBIvan Zugec
#6 field_ui_details-1862250-6.patch1.14 KBIvan Zugec
#2 trimmed_chars_configure.png14.42 KBklonos
#2 trimmed_chars_display.png8.27 KBklonos
#1 field_ui_details-1862250-1.patch788 bytesIvan Zugec
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ivan Zugec’s picture

Status: Active » Needs review
FileSize
788 bytes

Yes, I agree "Trim length" is confusing. I have attached a patch which just adds '#description' => t('The maximum number of characters this field can be.'), to the field element within the form.

klonos’s picture

Status: Needs review » Active
FileSize
8.27 KB
14.42 KB

...uploading screenshots for the issue summary.

klonos’s picture

Hey Ivan, thanx for taking a look at this and for providing a patch so soon (I kinda knew that it'd be a 1-2 liner thing). How about we simply add the word "characters" next to both the format display/overview as well as the configuration field (see attached screenshots/mockups)? Thanx in advance ;)

swentel’s picture

Issue tags: +Usability

Tagging

joachim’s picture

Status: Active » Needs work
Issue tags: +Novice, +Needs backport to D7

Just spotted this myself.

Definitely needs units. As one of my physics teachers used to always say, '600 what? bananas?'

I don't think that the patch is quite the right approach though. A field #suffix that says 'characters' (as illustrated in the screenshots) is what I think would be best.

Tagging for backport.

Ivan Zugec’s picture

Status: Needs work » Needs review
FileSize
1.14 KB

Here is an updated patch based on joachim advice (thanks :) ).

But, when I add '#suffix' => t('characters'), to the $element['trim_length'], the text "characters" appears below the number field.

joachim’s picture

Status: Needs review » Needs work
Ivan Zugec’s picture

Status: Needs work » Needs review
FileSize
1.21 KB

Not a problem. :) Updated patch.

vineet.osscube’s picture

I have tested "field_ui_details-1862250-8.patch" this patch working very fine for configuration field and display/overview of field content.

Regard's
Vineet

vineet.osscube’s picture

FileSize
62.03 KB

Uploading screenshots for tested "field_ui_details-1862250-8.patch" successfully.

Regard's
Vineet

joates’s picture

Assigned: Unassigned » joates
Status: Needs review » Needs work
FileSize
87.79 KB

I really think that we need to patch the actual formatter in text/lib/Drupal/text/Plugin/field/formatter/TextTrimmedFormatter.php to display in the UI what users actually expect to see, although this extends the scope of this issue to include:

  • the trim processing logic
  • any additional validation steps

Prototype screenshot:
1862250-trim-unit-screenshot.png

Feedback appreciated.
New issue or change title of this ?
I am willing to do the work to supply a provisional patch to get things moving :))

joates’s picture

upon further research..

this "feature" already exists in the D7 contrib module Smart trim

My proposed solution is definitely a feature so too late for 8.x, i should raise a new issue against 9.x.

joachim’s picture

> although this extends the scope of this issue to include:

That would be a bit of an understatement... can we keep this issue simple, so it can be backported, and make improvement afterwards?

joachim’s picture

Assigned: joates » Unassigned
Status: Needs work » Needs review

Oops, edit clash.

joachim’s picture

Status: Needs review » Needs work

Latest patch looks good, apart from the use of format_plural() -- it should not be within a t(). See http://api.drupal.org/api/drupal/core!includes!common.inc/function/forma...

Ivan Zugec’s picture

Status: Needs work » Needs review
FileSize
1.26 KB

Thanks for the help joachim.

Patch has been updated.

I do have a question, should we use the format_plural function for the "characters" string in the "field_suffix" property?

   // core/modules/text/lib/Drupal/text/Plugin/field/formatter/TextTrimmedFormatter.php
    $element['trim_length'] = array(
      '#title' => t('Trim length'),
      '#type' => 'number',
      '#field_suffix' => t('characters'),
      '#default_value' => $this->getSetting('trim_length'),
      '#min' => 1,
      '#required' => TRUE,
    );
    return $element;
joates’s picture

sorry if i'm the only person who doesn't think adding a prefix suffix to this field is an "improvement" but before this gets commited it's important to understand what this value actually is.. and that the way you choose to describe it in the UI could in fact cause more confusion to the user.

because of the way this function works:
text_summary()

it is highly unlikely (in fact almost impossible) to actually get 600 characters back from this function.. it is only used as a guide!

the documentation states:

$size: The desired character length of the summary.

IMO that could also be improved to explicitly state that the returned string will definitely not be exactly 600 characters (or whatever the setting value is)

To be clear,
i'm not trying to block this "fix", i just think we need to think about what this value represents :))
i definitely agree that the value is misleading and needs better clarification in the UI..
how to best do that to inform the user is my only concern.

thanks

joates’s picture

patch & screenshot for an alternate solution..

1862250-18-screenshot.png

joachim’s picture

Explaining just how the slightly mysterious trimming system works is definitely a good thing!

joates’s picture

Component: field_ui.module » text.module
FileSize
22.52 KB
21.43 KB

well #18 is actually no different than the patch from Ivan in #1, so sorry for that :((

i just think that this looks wrong (besides the fact it doesn't accurately describe how the value is used)..
1862250-suffix-screenshot-eww.png

how do you feel about replacing the word "length" with "breakpoint" ?

example:
1862250-trim-breakpoint-screenshot.png

klonos’s picture

WRT #11, I think that instead of:

Trim unit*
( ) Words   (*) Characters

Trim length*
[ 600             |+|-]

...this (inline drop-down for chars/words) would look better:

Trim length*
[ 600             |+|-]   [ words/characters   |v]

- It feels more natural (e.g. "600 characters" or "60 words" instead of "characters 600" and "words 60")
- Having the widgets inline is more compact and space-saving

Stalski’s picture

Assigned: Unassigned » Stalski
Status: Needs review » Needs work

I'll create the patch as soon as a usability expert has decided which direction to take in this issue.
The patch itself will be easy and I'll take this as soon as decisions are made.

I would have created a patch with most of the things suggested here, but I guess this would need review afterwards anyway. I'll ping yoroy to take a look at this.

yoroy’s picture

Status: Needs work » Needs review

Adding another unit (words) would make this a feature, not a bug fix. Probably best to focus on clarifying the existing feature as is here. (not to sure about the usefulness of 'words' either)

For the label:
"Trim breakpoint" is quite abstract. Why not "Summary length", seems easier to comprehend to me.

Nitpicking the description:
it's not the summary that gets truncated I think? The *body* gets truncated to *create* the summary. I'd prefer to not have to use 'truncated' at all.

My rewrite would be something like:

"The summary is created at the last full sentence within the allowed length."

Stalski’s picture

Status: Needs review » Needs work

Thx yoroy!
I'll create the patch asap.

Stalski’s picture

Issue summary: View changes

...adding screenshots.

acabouet’s picture

Assigned: Stalski » acabouet
Issue summary: View changes
Status: Needs work » Needs review
FileSize
892 bytes

New patch based on feedback in issue comments. Updated field label and description.

joshi.rohit100’s picture

Submitted the patch. I think, 'Body' word will be good than 'Summary' as it is trimming the actual body content. So thhis will not create any confusion.

yoroy’s picture

Thanks for working on this. You're right about using 'Body' instead of 'Summary', I was only thinking about this in context of the teaser view mode, but that doesn't necessarily have to be the case.

What about this:

jsobiecki’s picture

Issue tags: +dcwroc2014
rwojenka’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The latest patch doesn't apply to the latest head.

jsobiecki’s picture

Assigned: acabouet » jsobiecki

I'm working on re-roll.

rpayanm’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
1.27 KB

rerolled...

dahousecat’s picture

Patch from #31 applied cleanly.

Screen shot collapsed:

1862250-31 preview collapsed

and expanded:

1862250-31 preview expanded

Bojhan’s picture

What about including the word "text or "characters", for example Body text lenght

thomasdegraaff’s picture

I don't think including the word 'text' or 'characters' adds value. The field description already explains how the body length is defined.

Bojhan’s picture

That description is pretty awful though and descriptions are there to "add" not replace useful labels. People rarely read descriptions.

amanire’s picture

I've revised the patch in #31 so that it is not specific to the Body field. As you can see in the attached screenshots, this would lead to even more confusion when applied to other text fields, e.g. in the following case, "Description".

Only local images are allowed.
Only local images are allowed.

I also made a decision not to use the field label in the description since assumptions would have to made about converting to lowercase, "The description". Instead, I followed the convention that appears to be commonplace elsewhere and simply say, "The field".

Only local images are allowed.
Only local images are allowed.

I agree that the description text could use some revision. The phrasing is still awkward.

Status: Needs review » Needs work

The last submitted patch, 36: 1862250-trim-field-description-36.patch, failed testing.

amanire’s picture

Status: Needs work » Needs review
FileSize
1.38 KB

Revising patch in #36 to pass testing

cluther’s picture

I've verified that patch applies cleanly and that the label description and help text are as expected.
image

cluther’s picture

Status: Needs review » Reviewed & tested by the community
amanire’s picture

In keeping with the initial motivation for this issue, this patch re-adds the "characters" suffix to the input number field. I think this is key to clarifying the units and there's no good explanation in this thread as to why it was removed. I think it was an oversight.

I also shorted the length of the number input field with an inline style. This makes it easier to read and I don't see any obvious reasons why it can't be done this way as opposed to using a common class.

amanire’s picture

Status: Reviewed & tested by the community » Needs review

Changing status

amanire’s picture

The site builder shouldn't have to expand the settings and read the description to get the sense that the trim length is a maximum. With the patch in #41, it could be misconstrued to be a fixed length. I've rewritten the description to be more fluid. This patch also removes the field label from the collapsed version for brevity.


amanire’s picture

Removed duplicate comment.

chris_h’s picture

Status: Needs review » Needs work

The body field isn't always going to have a label of 'body', and it can make for awkward reading with other labels in there.

I suggest amending to:

Label: Trimmed limit

The description isn't quite right, either, as if a summary *is* set, it ignores the character limit. I suggest amending to:

If the summary is not set, the field will end at the last full sentence before this character limit.

The description on the overview page (eg before you click the configure icon) would also need to be updated.

amanire’s picture

Great points, @chris_h. I've updated the language accordingly. However, instead of completely removing the field label, I took a hint from the field settings UI and added the field label to the description. I think it adds clarity, reads well and is consistent with the UI elsewhere. Instead of

If the summary is not set, the field will end at the last full sentence before this character limit.

It now says,

If the summary is not set, the trimmed [field-name] field will end at the last full sentence before this character limit.

In the following screenshots, the field name is "Description":

After some consideration, I decided to remove the styling for the trimmed input field width. This really should be a CSS class, e.g. 'field-number--small' that is styled in the admin theme. I'll create a new ticket (for Seven) proposing this formatting. It seems necessary, since the size attribute doesn't set the width for number fields.

amanire’s picture

Status: Needs work » Needs review
amanire’s picture

Assigned: jsobiecki » Unassigned

Following guidelines at https://www.drupal.org/node/2172049

Reno Greenleaf’s picture

Reviewed https://www.drupal.org/files/issues/1862250-trim-field-description-46.patch
Works fine. "characters" word is added after number.

aburke626’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed https://www.drupal.org/node/1862250#comment-9533389 and it is displaying correctly.

xjm’s picture

Priority: Minor » Normal

Thanks for the reviews and especially the screenshots!

As a usability improvement, this issue is prioritized during the beta per https://www.drupal.org/core/beta-changes.

I'm going to trigger a retest of the patch since it was last updated in January.

Bojhan’s picture

Priority: Major » Normal
xjm’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Looks like it's still good (not sure what happened with the priority there though). Per #51, committed and pushed to 8.0.x. Thanks!

Moving to 7.x for backport.

  • xjm committed 2165306 on 8.0.x
    Issue #1862250 by amanire, Ivan Zugec, joates, yoroy, joshi.rohit100,...
David_Rothstein’s picture

Version: 8.0.x-dev » 7.x-dev
Novitsh’s picture

Status: Patch (to be ported) » Needs review
FileSize
1.23 KB

D7 patch attached. Please verify.

EDIT: Just a note for D7 the localised versions of Drupal should also be translated.

HeimdallJHM’s picture

seems right, but i think the description should be something like "If the summary is not set, the trimmed [field-name] field will end at the last full sentence before this character limit."

HeimdallJHM’s picture

Status: Needs review » Needs work
sdstyles’s picture

Status: Needs work » Needs review
FileSize
1.32 KB
674 bytes
43.34 KB

Changed field description according to description from D8 patch.

Novitsh’s picture

@sdstyles thanks for the updated version. Works for me.

HeimdallJHM’s picture

al right! I see no other problem right now. RTBC?

Novitsh’s picture

Status: Needs review » Reviewed & tested by the community
Novitsh’s picture

Seems like a good to go for me.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs work
+    $summary = t('Trimmed limit: @trim_length characters', array('@trim_length' => check_plain($settings['trim_length'])));

The @ already runs check_plain(), so we don't want an extra check_plain there also.

Besides that relatively small issue, this looks good to go. Unfortunately it changes translatable strings; I missed that it did that and I didn't get to it early enough in the release cycle to be able to do that (https://www.drupal.org/node/1527558). We can try to get it in early in the next release cycle (if it's ready by then), though. Sorry.

One other thing:

+ '#description' => t('If the summary is not set, the trimmed %label field will end at the last full sentence before this character limit.', array('%label' => $instance['label'])),

Is this really an accurate description of what text_summary() does? Perhaps a simpler description would be better anyway, something like "If the summary is not set, the trimmed %label field will be shorter than this character limit"?

Novitsh’s picture

Rewrote the patch from #60 to correspond the remarks of @David_Rothstein.

Novitsh’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 66: 1862250-trim_field_description-66.patch, failed testing.

Novitsh’s picture

Bad patch, attaching new one.

Novitsh’s picture

Status: Needs work » Needs review
dani3lr0se’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
46.79 KB
58.5 KB

Looks good to me. I like it. I admit when I first started out with Drupal and needed to use this feature it was a slight bit confusing. So I can appreciate this one.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +7.42 release notes

Committed to 7.x - thanks!

Not sure if that small wording change we added to the Drupal 7 patch in the end would make sense for Drupal 8 also.. if so I guess there can be a followup issue?

  • David_Rothstein committed 405e861 on
    Issue #1862250 by amanire, Ivan Zugec, Novitsh, joates, sdstyles, yoroy...

Status: Fixed » Closed (fixed)

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