Problem/Motivation
When you have 2 or more text with summary fields and 1 has required summary but the others do not. The required summary is hidden.
The summary form element for the first text field is concealed and requires an additional "Edit Summary" click to reveal the summary form element.
Steps to reproduce
On a content type:
1. Create a "text with summary" field with summary input and required summary.
2. Create a second "text with summary" field with summary input. Do not require summary.
3. Attempt to create a new node.
Proposed resolution
The form should expose the summary form element for the first text field, and there should be no "Hide Summary" link.
From original posting
If I comment out line 41 of "text.js" ($link.trigger('click');), the summary element is not concealed but the "Hide Summary" link remains.
Inserting a simple logging statement (like console.log($(this));) before line 13 (var $widget = $(this).closest('.js-text-format-wrapper');) indicates that this code is getting executed for both fields.
A required class is added to the summary element, at least in my configuration. A simple fix is therefore to filter out required text summaries.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #36 | after-patch-one-required-summary-textarea.png | 11.26 KB | gaurav-mathur |
| #36 | before-patch-one-required-summary-textarea.png | 12.07 KB | gaurav-mathur |
| #33 | 3145850-33.patch | 3.45 KB | smustgrave |
| #33 | interdiff-30-33.txt | 0 bytes | smustgrave |
| #25 | 3145850-25-tests-only.patch | 1.93 KB | smustgrave |
Issue fork drupal-3145850
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
Comment #2
natedouglas commentedThis appears to work without breaking my other content types.
Comment #3
natedouglas commentedComment #4
Rkumar commentedQueueing for tests.
Meanwhile, let me try to replicate the scenario.
Comment #5
nod_That's a good one, thanks. And you're correct about the fix.
I would check for the required attribute instead of the class.
I would use the required attribute and let the browser deal with evaluating the selector:
.find('.js-text-summary:not([required])')Also you edited the text.js file directly, have a look at the top of the file to see that we now use *.es6.js files for source: #2815083: Drupal core now using ES6 for JavaScript development
Comment #6
natedouglas commentedAh, thanks. Sorry, I'm completely unfamiliar with how JS is processed in Drupal. And, apparently, can't read.
I think I did the interdiff right.
Comment #7
nod_no worries. Was almost there :) you had the change in the right file and you needed to run
yarn run build:jsto update the text.js file. for interdiffs, it's better to name them.txtto make sure the testbot doesn't run them.Provided the update text.js file.
But here we need tests to make sure we don't run into this later.
Comment #8
nod_First pass at making a test
Comment #10
pankaj.singh commentedComment #11
pankaj.singh commentedTested the patch from #9 on 9.1.x. Patch worked for me as the form exposes the summary form element for the first text field, and there is no "Hide Summary" link for the Text1(marked required summary), as expected behavior.
Please refer to the attached screenshots with detailed insights. RTBC+1
Comment #12
pankaj.singh commentedComment #13
pankaj.singh commentedComment #16
amateescu commentedI think it would be easier if we change the field widget to not output the
js-text-summaryclass when the field is required.I tested the patch from #8 first but it has a small problem, if a theme overrides text.js (like Bootstrap does), the fix in core's text.js is not carried over without an additional patch for that theme.
Comment #17
nod_Needs to be confirmed btut we might still need to make the JS change to handle required status changes through JS #states API. (a non required issue summary becomes required after a change in another field).
Comment #18
gauravvvv commentedFixed MARKED SNIFF VIOLATIONS of patch #16, Attached interdiff for the same.
Comment #21
s_leu commentedPatch doesn't apply anymore on 9.3.18, here's a re-roll.
Comment #22
pooja saraah commentedTested the patch #21 patch applied successfully in drupal-9.5.x-dev.
Comment #23
pooja saraah commentedComment #24
abhijith s commentedApplied patch #21 on 9.5.x and the required summary form element is exposed after this patch.
Before patch;

After patch:

Comment #25
smustgrave commentedThank you for a super clear description and testing steps. Following those I was able to confirm the bug and with the patch confirm it's fixed.
This patch is the same as #21 but also uploading a tests-only patch for the person who will commit this.
Comment #27
smustgrave commentedLooks like a good test
Comment #28
quietone commentedThe issue summary does not have the standard template. Meaning there is no proposed resolution so reviewers can't confirm that the agreed to fix has been made. Adding tag.
Skimming the comments I see a question in #17 has not been answered. Setting to NW.
I also don't see a code review, my few comments below are not a full review.
Looks like we can skip creating $page.
Messages are no longer included is assertions.
Comment #29
smustgrave commentedComment #30
smustgrave commentedAddressed #28
Took a look at #17 by
Hiding a text summary field until the title is filled in
When the field appeared it's summary was required
The default body field was not requiring summary.
So think we are good there.
Also updated issue summary so removing that tag.
Comment #31
deepalij commentedComment #32
deepalij commentedPatch #30 failed to apply.
Re-roll the patch.
Comment #33
smustgrave commentedComment #35
smustgrave commentedPasses 10.1 too
Comment #36
gaurav-mathur commentedApplied patch #33 works fine with expected results on Drupal 10.1.x-dev
Refer to the screenshot
Comment #37
jungle#30 faild to apply, because of #3181778: [w/c September 17th] Replace t() with $this->t() in all plugins
interdiff-30-33.txtin #33 is empty. The following is supposed to be its content.Thanks!
Comment #40
kunal_sahu commentedHi I have created an MR . Please Merge. thanks
Comment #41
smustgrave commented@kunal_sahu thanks for the interest but the patch #33 was already reviewed. So the MR is just reuploading the work that was already done. So removing credit for that unless there was something you were fixing.
Thanks
Comment #42
gauravvvv commentedUpdated attributions
Comment #43
larowlanNo need for the message here, as @quietone pointed out above in #28.
Comment #44
larowlanOn second thoughts, I can fix that on commit.
Comment #45
larowlanUpdating credits
Comment #49
larowlanFixed on commit
Committed to 10.1.x and backported to 10.0.x and 9.5.x
Manually tested with a multi-cardinality field as there's some JS regarding that, but it need not run if the summary is optional - so all good.