Problem/Motivation
- Create a long text + summary field and set it to be multivalued on a content type of your choice.
- Create a node of that content type.
- On the node edit form, the summary part of the field is not displayed, and neither is the expected "Show summary" link.
Proposed resolution
On multi-value fields add the Edit summary link above each delta's textarea.
Remaining tasks
Needs frontend framework manager review
User interface changes
The Edit summary link appears for multi-value long text with summary fields above the delta's textarea.
Original report by amoebanath
Create a long text + summary field and set it to be multivalued on a content type of your choice.
Create a node of that content type.
On the node edit form, the summary part of the field is not displayed, and neither is the expected "Show summary" link.
I came across this issue on 8.1.10, is also (as of writing) present in 8.3.x.
Demo on simplytest.me, on 8.3.x branch:
https://r1h7e.ply.st/node/add/page
This issue has come up before:
https://www.drupal.org/node/822128
And there is another thread looking at the summary not showing up in certain circumstances:
https://www.drupal.org/node/2626716
Comment | File | Size | Author |
---|---|---|---|
#48 | core-2817081-show-edit-summary-48.patch | 2.68 KB | nod_ |
#46 | after--patch--edit-summary.png | 24.7 KB | vikashsoni |
#46 | before--patch-no-edit-summary.png | 22.38 KB | vikashsoni |
#45 | core-2817081-show-edit-summary-44.patch | 2.79 KB | nod_ |
Issue fork drupal-2817081
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:
- 2817081-show-edit-summary changes, plain diff MR !606
Comments
Comment #2
amoebanath CreditAttribution: amoebanath at ComputerMinds commentedSo in
WidgetBase.php : formMultipleElements() : 172
it's declared that "For multiple fields, title and description are handled by the wrapping table.". I guess we need to clarify whether that is indeed true, and the table is doing something wrong, or if, actually, that is not entirely true.Removing the
'#title_display' => 'invisible',
seems to put things back how I'd expect, but I don't know what the effect would be on other widgets. Possibly this would have unintended effects on those?Avoiding that, adding
$fullLabel.removeClass('visually-hidden');
to core/modules/text/text.js achieves the desired effect also, without affecting all the other widgets.Both suggestions, though, end up displaying the slightly nasty title set on line ~176. If we're going to show the title, I'd suggest we make that somehow much nicer?
I guess there's somebody that knows and understands a bit more that can clarify which way things ought to be?
Comment #6
hudriStill present in 8.5. Given that text fields are the most basic datatype in any CMS I think this bug deserves a "major" priority.
Comment #9
joekersIt's still present in 8.7. I found this for when help text is added but doesn't help with it being a multi-value field:
https://www.drupal.org/project/drupal/issues/2626716
Comment #10
Baysaa CreditAttribution: Baysaa as a volunteer and at Fabb commentedThis issue seems isolated to multi-value summary fields only, since the Help text issue linked in the issue summary is now fixed. I expanded the TextareaWithSummaryTest (FunctionalJavascript) to include a test for a multi-value Body field.
With the actual fix, I went with just prepending the Edit Summary button to the wrapper instead of the label, keeping the labels hidden (with: (value 1) etc). To achieve this I simply checked for an existence of a multi-value table container within the parents of the summary field.
There is 1 slight visual/aesthetic drawback of my method, there are situations where a single value text+summary field could be nested within a multi-value field (such as Paragraphs). In this case, the Edit summary link is displayed above the visible label instead of after it. It's not ideal but it works. I thought I'd get a patch in and get the ball rolling at least.
Comment #13
rensingh99 CreditAttribution: rensingh99 at Red Crackle commentedHi,
I have reviewed the patch #10 and it's working great.
Below is the output screenshot body text before applying the patch.
Below is the output screenshot body text after applying the patch.
Thanks,
ren
Comment #15
xjmThanks for trying to solve this persistent issue!
This looks promising, but it doesn't apply to 9.1.x, so we need the D9 version of the patch.
Also tagging for review of the JS from the frontend framework manager.
Thanks!
Comment #16
AndyF CreditAttribution: AndyF at Fabb commentedThanks @baysaa! Tried it out locally and it works for me.
.closest()
here: it returns at most one matching element from its DOM ancestors.field-multiple-table
: could we use ajs-
class or (perhaps better) a data attribute?Nit: You could store
$(this)
in a variable.Nit: Just a style thing but personally I'd go for an explicit conditional here: I find that a bit more readable.
Comment #17
AndyF CreditAttribution: AndyF at Fabb commentedComment #18
Baysaa CreditAttribution: Baysaa as a volunteer and at Fabb commentedThanks @xjm and @AndyF for the reviews.
Here's an updated D8 patch, taking AndyF's suggestions on board. Using `jQuery.closest()` in combination with `jQuery.find()` I was able to resolve the aesthetic issue mentioned in #10
I'll work on a D9 patch later today.
Tests have not changed.
Comment #19
Baysaa CreditAttribution: Baysaa as a volunteer and at Fabb commentedAdded interdiff, but didn't get uploaded with last commend. Here's it.
Comment #20
AndyF CreditAttribution: AndyF at Fabb commentedComment #21
Baysaa CreditAttribution: Baysaa as a volunteer and at Fabb commentedComment #22
Baysaa CreditAttribution: Baysaa as a volunteer and at Fabb commentedreroll diff wasn't required.
Comment #23
Baysaa CreditAttribution: Baysaa as a volunteer and at Fabb commentedHere's a D9 reroll against 9.1.x
Worked in collaboration with @AndyF over zoom :)
Comment #24
AndyF CreditAttribution: AndyF at Fabb commented#18 Looks good to me, thanks! I've tested the 8.9 and 9.1 patches locally, and also checked that the generated JS matches. Tentatively moving back to RTBC as I only helped with the 9.1 reroll rather than the actual update... (:
Comment #25
alexpottI've tested this patch and it fixed the problem as described in the issue summary and has automated test coverage. Nice.
There are issues around the default value field whilst creating a field but they exist in HEAD and there's an issue already for it - #3115978: After enabling Require Summary on a field can't save the field
One consideration is whether this is a good idea to add to ALL multiple value fields. I think it is.
I can't remove the "Needs frontend framework manager review" tag as I'm not one but as far as I can see this issue looks good.
Comment #26
nod_Make sure you have the JavaScript tag on javascript issue, otherwise it's very hard to track them :)
I'm not too happy about the whole thing since we're adding the element in different places depending on the cardinality. The styling on seven is not too bad, we go from normal weight to bold and a margin gets changed. But on claro the weight, size, margin and it doesn't look good to be honest.
I have a less invasive take that doesn't conflict with the styling and that will work when the label is hidden outside of a multi-value field. I wanted to remove the part about the placeholder because now we (should) have a label all the time #933004: Test that all form elements have a title for accessibility but that's scope creep.
no interdiff since it's a different approach.
Comment #27
lauriiiI like the approach in #26 because it makes the styling and markup more consistent. I'm unsure what to think about using
visually-hidden
as the integration point. Given that the patch has a comment explaining what that extra big of logic is for, it's probably fine. Leaving this for needs review in case others have thoughts on the new approach.Comment #28
Baysaa CreditAttribution: Baysaa as a volunteer and at Fabb commented#26 +1, a cleaner and neater solution than mine imho.
Comment #29
alexpottI've stared at #26 for a while pondering it. What I've come to wonder if is that adding the edit summary link inside the label is semantically correctly. It's not a label right?
Comment #30
nod_I think it's borderline? The spec says that a button element inside a label is valid under certain conditions. From what I understand we're not fulfilling the conditions… then again, it's not broken?
In any case this is not something we should fix only when the fields are in a tabledrag, so as far as this issue is concerned I'd go with this even if it's borderline to make it in line with the rest. It's been many years and I haven't seen it come up in accessibility reviews before.
Comment #31
alexpott@nod_ thanks for pointing me to the standards. Funnily enough I think we're pretty clearly in the bad example area here.
TIL if you click on the label for a text box the carat is positioned in the text box.
However this of course is not made any worse by the patch. It only make me question whether or not we should review this from an accessibility perspective first and then the fix might be to fix the accessibility issue which has the happen co-incidence of fixing this issue. I'm going to ask in the accessibility channel.
Comment #32
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commentedAlex asked about this in the accessiblity slack channel, and I chatted a bit with nod_.
The "edit summary" button is horrible in lots of ways. More on that later.
Re. #30:
Where, exactly? I don't think it says that at all. What it does say explicitly, is that a
<label>
must contain "no descendant labelable elements unless it is the element’s labeled control".A
<button>
is a labelable control, so it can only be a descendant of a<label>
, if the label is for the button. But a button's accessible name comes from it's content (unless ARIA changes that). The following examples would be permitted (but they are rather perverse):In the case of the long text + summary Drupal widget, we have this markup:
This isn't permitted by the HTML content model, because the
<label for>
isn't for the<button>
inside it.Re. #31:
This is fine by the HTML content model!
The part about reducing the checkbox activation area isn't very significant, unless the combined width of the checkbox and "I agree to" adds up to less than 44px. The important thing is that the link text can be (a) identified as a link, and (b) distinguished from the rest of the label. (The Seven theme fails badly here - #2958282: Links inside surrounding text fail WCAG Use-of-Color in Seven theme.)
On to the other problems with the "edit summary" and "hide summary" buttons....
In a single-value, long-text-and-summary widget:
aria-expanded
.<label>
for another element, so it fails the HTML content model too.For a multi-value, long-text-and-summary widget:
.visually-hidden
class. That means the "edit summary" button isn't visible. This is the problem this current issue is trying to solve.Patch #26:
This solves the problem of the "edit summary" button being invisible in multi-value scenario.
It doesn't help with any of the other problems though. The behaviour and names are still horrible.
Patch #23:
This is better! It solves problems 1, 2, 3.2, and 3.3 which I described for single-value fields. But... it only fixes them for multi-value fields. The single value fields still have these problems. I think that's what @nod_ was saying in #26? ("I'm not too happy about the whole thing since we're adding the element in different places depending on the cardinality.")
What I'd do:
Comment #33
nod_Thanks for the thorough review!
You're correct, I did not understand the spec correctly :)
From what I get we could use a detail element to wrap the summary field in, it's already accessible, element stays in one place. Quick and dirty patch to put a details element seems to be working but it'll be a challenge visually.
Not sure how "clean" the solution should be here. I have a quickfix in #26, but fixing it "properly" will take some time and given that this is major I don't know.
Comment #34
nod_all right, opened #3155130: "Edit summary" toggle on text fields has many accessibility issues as a major bug.
I propose we go with #26. The situation will be as bad on multi-value fields as it is on single fields, instead of bad for single fields and unusable for multi-value fields.
Comment #35
tanubansal CreditAttribution: tanubansal at Salsa Digital commentedTested via above mentioned steps and the latest patch. Issue is still there. I can't see 'Edit summary' while creating a content
Comment #36
samiullah CreditAttribution: samiullah at Salsa Digital commentedTested the latest patch on simplytest.me
We are able to see Edit Summary for multivalued field with text + summary
We are seeing a broken UI in bottom of field that needs a fix
Moving back to need fix
Comment #38
ldwyer CreditAttribution: ldwyer as a volunteer commentedI am also experiencing this issue with a muli-value body field - the edit summary link is gone - Drupal 8.9.6.
I tried patch #10 and #26 (random choices) and neither worked for me.
Comment #40
nod_The patch is for 9.2 so not sure how well it'd work in 8.9, should be similar, the js file didn't change in a long time. Were the cache cleared before testing? if you have JS aggregation activated, it won't work until you clear the cache.
The spacing issue in #36 doesn't seem related, it's present with or without this patch. Once a textarea with summary is multi value the CSS leave the existing margins.
The accessibility concerns are not ignored, a proper solution need to be found here #3155130: "Edit summary" toggle on text fields has many accessibility issues. Given that an a11y fix will impact html/css/js it might take a while to finalize. In the meantime we can give back access to the feature (and the data) for users by making it as broken for multi-value field as it is today for single-value fields.
Comment #42
codebymikey CreditAttribution: codebymikey at Zodiac Media commentedThis issue also apparently affects Drupal 7 in #980144: Issues with "required, multiple" fields in forms, so will probably need porting when this finally lands.
Comment #43
nod_The MR fixes the cosmetic issues, for the true accessibility fix see #3155130: "Edit summary" toggle on text fields has many accessibility issues. This one is an intermediate step.
Comment #45
nod_well when the fork was made 9.3.x didn't exist and now we can't create a branch from it easily. Instead of figuring it out here is a good old patch for 9.3
Comment #46
vikashsoni CreditAttribution: vikashsoni as a volunteer and at Zyxware Technologies commentedAfter patch we can access edit summary option
Thanks for the patch for ref sharing screenshot
Comment #47
vikashsoni CreditAttribution: vikashsoni as a volunteer and at Zyxware Technologies commentedThanks
Comment #48
nod_fixing code checks
Comment #49
Baysaa CreditAttribution: Baysaa as a volunteer and at Fabb for Gizra commentedPatch looks good. Ok to RTBC?
Comment #51
nod_Comment #52
nod_back to rtbc
Comment #54
lauriiiCommitted b57729b and pushed to 9.3.x. Thanks!
Comment #56
eelkeblokIt sounds like an open and relevant ticket for D7 is #822128: "Textarea + summary" widget broken when field allows multiple values (followup) and associated JavaScript uses fragile selectors, although that is 12 years old... 🤷♂️
Comment #61
quietone CreditAttribution: quietone at PreviousNext commentedClosed #2826356: Summary hidden if Text field has Unlimited number of values as a duplicate, adding credit.