Problem/Motivation
The markup for the "Edit summary" button for text_with_summary fields is not wrapped with Drupal.theme, meaning it cannot be easily overriden.
Steps to reproduce
- Have a content type that has a text_with_summary field with "Display summary" enabled in the field settings
- In a custom module, attempt to override the markup of this field.
- Realize there is no way to override it directly using Drupal.theme
Remaining tasks
In the text module's text.js file there is the following code:
// Set up the edit/hide summary link.
const $link = $(
`<span class="field-edit-link"> (<button type="button" class="link link-edit-summary">${Drupal.t(
'Hide summary',
)}</button>)</span>`,
);
That is outputting some markup without using Drupal.theme().
That markup should be wrapped with a theme function so themes can override it.
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
The "Edit summary / Hide summary” button that appears on text_with_summary fields above the text area has been wrapped with Drupal.theme, making it easy to override.
Comments
Comment #2
rodrigoaguileraAttached is a simple patch that enables that markup to be themable.
I don't think it needs tests since it will require a costly JS test for checking how that markup can now be changed. I guess that is been tested somewhere else.
Comment #3
ippy commentedHi, yes, we just encountered the same issue. So I'm happy (sort of) to discover this in the issue queue.
I'm won't patch core for something so relatively trivial on production site, but I did test it on a dev copy and can confirm that it applied cleanly on 8.6.10
Not much help though, as we have no opportunity right now to test it further (front end dev is busy elsewhere).
Sorry, I'm aware this is not a massively helpful comment, but promise I will leave a note if we come back to this issue... and thank you for your efforts to resolve it :)
Comment #7
ranjith_kumar_k_u commentedThe last patch failed to apply on 9.2, so re-rolled for 9.2
Comment #8
kapilv commentedComment #9
sulfikar_s commentedHi, I've corrected the custom commands issues on #7 patch and rerolled to a new patch. I'm also attaching the interdiff.
Please review.
Comment #10
sulfikar_s commentedCorrected the last failed custom commands. Please review.
Comment #11
gauravvvv commentedComment #12
gauravvvv commentedComment #15
ptmkenny commentedComment #16
ankithashettyRerolled the patch in #11 and fixed custom command errors, thanks!
Comment #19
smustgrave commentedThis looks like a great idea and improvement.
1. will need a reroll for 10.1
2. will need a test
3. issue summary update
Thank you!
Comment #20
_pratik_Related to point 1 .Rerolled patch.
Thanks
Comment #21
_utsavsharma commentedFixed CCF in #20.
Comment #25
smustgrave commentedGoing to tag for novice for updating the summary and creating an MR. Make sure the MR is passing before setting in review please.
Comment #26
mdranove commentedUpdated issue summary
Comment #27
mdranove commentedComment #28
mdranove commentedComment #29
mdranove commentedComment #31
mdranove commentedCreated an MR with the js changes from latest patch and a test + supporting files. Moving to NR
Comment #32
mdranove commentedComment #33
smustgrave commentedFeedback appears to be addressed. Manually testing and summary box appears to be working as before.
Comment #34
longwaveBackported to 11.x, not backported further because this is a new feature.
Committed and pushed 6f2da240fc8 to main and 31998326026 to 11.x. Thanks!