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

  1. Have a content type that has a text_with_summary field with "Display summary" enabled in the field settings
  2. In a custom module, attempt to override the markup of this field.
  3. 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.

Issue fork drupal-3040302

Command icon 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

rodrigoaguilera created an issue. See original summary.

rodrigoaguilera’s picture

Status: Active » Needs review
StatusFileSize
new2.22 KB

Attached 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.

ippy’s picture

Hi, 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 :)

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

ranjith_kumar_k_u’s picture

StatusFileSize
new2.24 KB

The last patch failed to apply on 9.2, so re-rolled for 9.2

kapilv’s picture

core/modules/text/text.es6.js
35:27   error  Replace `Drupal.theme('textEditSummaryButton',·Drupal.t(⏎············'Hide·summary'` with `⏎············Drupal.theme('textEditSummaryButton',·Drupal.t('Hide·summary'))`  prettier/prettier
  37:11   error  Delete `))`                                                                                                                                                               prettier/prettier
  76:104  error  Replace `⏎··········title⏎········` with `title`                                                                                                                          prettier/prettier
sulfikar_s’s picture

StatusFileSize
new990 bytes
new2.15 KB

Hi, I've corrected the custom commands issues on #7 patch and rerolled to a new patch. I'm also attaching the interdiff.

Please review.

sulfikar_s’s picture

StatusFileSize
new2.15 KB

Corrected the last failed custom commands. Please review.

gauravvvv’s picture

StatusFileSize
new2.16 KB
gauravvvv’s picture

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ptmkenny’s picture

Status: Needs review » Needs work
ankithashetty’s picture

Status: Needs work » Needs review
StatusFileSize
new2.12 KB
new2.99 KB

Rerolled the patch in #11 and fixed custom command errors, thanks!

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update, +Needs tests

This 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!

_pratik_’s picture

StatusFileSize
new959 bytes

Related to point 1 .Rerolled patch.
Thanks

_utsavsharma’s picture

StatusFileSize
new941 bytes
new941 bytes

Fixed CCF in #20.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mademo made their first commit to this issue’s fork.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Issue tags: -Needs tests +Novice

Going to tag for novice for updating the summary and creating an MR. Make sure the MR is passing before setting in review please.

mdranove’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

Updated issue summary

mdranove’s picture

Issue summary: View changes
mdranove’s picture

Issue summary: View changes
mdranove’s picture

Issue summary: View changes

mdranove’s picture

Status: Needs work » Needs review

Created an MR with the js changes from latest patch and a test + supporting files. Moving to NR

mdranove’s picture

Issue summary: View changes
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Feedback appears to be addressed. Manually testing and summary box appears to be working as before.

longwave’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Backported to 11.x, not backported further because this is a new feature.

Committed and pushed 6f2da240fc8 to main and 31998326026 to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • longwave committed 31998326 on 11.x
    fix: #3040302 "Edit summary" button for the text with summary widget has...

  • longwave committed 6f2da240 on main
    fix: #3040302 "Edit summary" button for the text with summary widget has...

Status: Fixed » Closed (fixed)

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