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?
Comment | File | Size | Author |
---|---|---|---|
#71 | trimmed_2.png | 58.5 KB | dani3lr0se |
#71 | trimmed_1.png | 46.79 KB | dani3lr0se |
#69 | 1862250-trim_field_description-67.patch | 1.28 KB | Novitsh |
#66 | 1862250-trim_field_description-66.patch | 1.28 KB | Novitsh |
#60 | d7_field_description.png | 43.34 KB | sdstyles |
Comments
Comment #1
Ivan Zugec CreditAttribution: Ivan Zugec commentedYes, 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.Comment #2
klonos...uploading screenshots for the issue summary.
Comment #3
klonosHey 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 ;)
Comment #4
swentel CreditAttribution: swentel commentedTagging
Comment #5
joachim CreditAttribution: joachim commentedJust 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.
Comment #6
Ivan Zugec CreditAttribution: Ivan Zugec commentedHere 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.Comment #7
joachim CreditAttribution: joachim commentedAh, my mistake. It's http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.ht... that's needed here.
Comment #8
Ivan Zugec CreditAttribution: Ivan Zugec commentedNot a problem. :) Updated patch.
Comment #9
vineet.osscube CreditAttribution: vineet.osscube commentedI 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
Comment #10
vineet.osscube CreditAttribution: vineet.osscube commentedUploading screenshots for tested "field_ui_details-1862250-8.patch" successfully.
Regard's
Vineet
Comment #11
joates CreditAttribution: joates commentedI 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:Prototype screenshot:
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 :))
Comment #12
joates CreditAttribution: joates commentedupon 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.
Comment #13
joachim CreditAttribution: joachim commented> 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?
Comment #14
joachim CreditAttribution: joachim commentedOops, edit clash.
Comment #15
joachim CreditAttribution: joachim commentedLatest 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...
Comment #16
Ivan Zugec CreditAttribution: Ivan Zugec commentedThanks 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?
Comment #17
joates CreditAttribution: joates commentedsorry if i'm the only person who doesn't think adding a
prefixsuffix 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:
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
Comment #18
joates CreditAttribution: joates commentedpatch & screenshot for an alternate solution..
Comment #19
joachim CreditAttribution: joachim commentedExplaining just how the slightly mysterious trimming system works is definitely a good thing!
Comment #20
joates CreditAttribution: joates commentedwell #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)..
how do you feel about replacing the word "length" with "breakpoint" ?
example:
Comment #21
klonosWRT #11, I think that instead of:
...this (inline drop-down for chars/words) would look better:
- 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
Comment #22
Stalski CreditAttribution: Stalski commentedI'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.
Comment #23
yoroy CreditAttribution: yoroy commentedAdding 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."
Comment #24
Stalski CreditAttribution: Stalski commentedThx yoroy!
I'll create the patch asap.
Comment #24.0
Stalski CreditAttribution: Stalski commented...adding screenshots.
Comment #25
acabouet CreditAttribution: acabouet commentedNew patch based on feedback in issue comments. Updated field label and description.
Comment #26
joshi.rohit100Submitted 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.
Comment #27
yoroy CreditAttribution: yoroy commentedThanks 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:
Comment #28
jsobiecki CreditAttribution: jsobiecki commentedComment #29
rwojenka CreditAttribution: rwojenka commentedThe latest patch doesn't apply to the latest head.
Comment #30
jsobiecki CreditAttribution: jsobiecki commentedI'm working on re-roll.
Comment #31
rpayanmrerolled...
Comment #32
dahousecat CreditAttribution: dahousecat commentedPatch from #31 applied cleanly.
Screen shot collapsed:
and expanded:
Comment #33
Bojhan CreditAttribution: Bojhan commentedWhat about including the word "text or "characters", for example Body text lenght
Comment #34
thomasdegraaff CreditAttribution: thomasdegraaff commentedI don't think including the word 'text' or 'characters' adds value. The field description already explains how the body length is defined.
Comment #35
Bojhan CreditAttribution: Bojhan commentedThat description is pretty awful though and descriptions are there to "add" not replace useful labels. People rarely read descriptions.
Comment #36
amanire CreditAttribution: amanire commentedI'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".
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".
I agree that the description text could use some revision. The phrasing is still awkward.
Comment #38
amanire CreditAttribution: amanire commentedRevising patch in #36 to pass testing
Comment #39
clutherI've verified that patch applies cleanly and that the label description and help text are as expected.
Comment #40
clutherComment #41
amanire CreditAttribution: amanire commentedIn 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.
Comment #42
amanire CreditAttribution: amanire commentedChanging status
Comment #43
amanire CreditAttribution: amanire commentedThe 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.
Comment #44
amanire CreditAttribution: amanire commentedRemoved duplicate comment.
Comment #45
chris_h CreditAttribution: chris_h commentedThe 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.
Comment #46
amanire CreditAttribution: amanire commentedGreat 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
It now says,
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.
Comment #47
amanire CreditAttribution: amanire commentedComment #48
amanire CreditAttribution: amanire commentedFollowing guidelines at https://www.drupal.org/node/2172049
Comment #49
Reno Greenleaf CreditAttribution: Reno Greenleaf commentedReviewed https://www.drupal.org/files/issues/1862250-trim-field-description-46.patch
Works fine. "characters" word is added after number.
Comment #50
aburke626Reviewed https://www.drupal.org/node/1862250#comment-9533389 and it is displaying correctly.
Comment #51
xjmThanks 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.
Comment #53
Bojhan CreditAttribution: Bojhan as a volunteer commentedComment #54
xjmLooks 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.
Comment #56
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedComment #57
Novitsh CreditAttribution: Novitsh as a volunteer commentedD7 patch attached. Please verify.
EDIT: Just a note for D7 the localised versions of Drupal should also be translated.
Comment #58
HeimdallJHM CreditAttribution: HeimdallJHM at ASPgems commentedseems 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."
Comment #59
HeimdallJHM CreditAttribution: HeimdallJHM at ASPgems commentedComment #60
sdstyles CreditAttribution: sdstyles at FFW commentedChanged field description according to description from D8 patch.
Comment #61
Novitsh CreditAttribution: Novitsh as a volunteer commented@sdstyles thanks for the updated version. Works for me.
Comment #62
HeimdallJHM CreditAttribution: HeimdallJHM at ASPgems commentedal right! I see no other problem right now. RTBC?
Comment #63
Novitsh CreditAttribution: Novitsh as a volunteer commentedComment #64
Novitsh CreditAttribution: Novitsh as a volunteer commentedSeems like a good to go for me.
Comment #65
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedThe @ 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:
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"?
Comment #66
Novitsh CreditAttribution: Novitsh at Colruyt Group Services commentedRewrote the patch from #60 to correspond the remarks of @David_Rothstein.
Comment #67
Novitsh CreditAttribution: Novitsh at Colruyt Group Services commentedComment #69
Novitsh CreditAttribution: Novitsh at Colruyt Group Services commentedBad patch, attaching new one.
Comment #70
Novitsh CreditAttribution: Novitsh at Colruyt Group Services commentedComment #71
dani3lr0se CreditAttribution: dani3lr0se as a volunteer commentedLooks 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.
Comment #72
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedCommitted 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?