Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
tableselect.js
in Drupal core and media_library.view.js
in Media Library insert a checkbox input HTML element. Currently, markup of these elements is not overridable by themes.
Proposed resolution
Introduce a new Drupal.theme
callback for checkbox, and refactor the files above to use that for creating the markup of the checkbox.
Remaining tasks
Provide patchJS maintainer sign-offCreate change record
Comment | File | Size | Author |
---|---|---|---|
#16 | core-checkbox_theme_js-8.8.x-3024975-16.patch | 9.66 KB | quiron |
#16 | interdiff_3024975_9_16.txt | 3.5 KB | quiron |
#9 | interdiff_8_9.txt | 2.49 KB | quiron |
#9 | core-checkbox_theme_js-8.8.x-3024975-9.patch | 6.31 KB | quiron |
#8 | interdiff_2_8.txt | 3.94 KB | quiron |
Comments
Comment #2
huzookaComment #3
lauriiiWould be great to get feedback from the subsystem maintainers on where they think this new theme function should be located.
Comment #4
huzookaComment #5
nod_Adding this theme function to all pages using core/drupal seems a bit overkill.
I would create a new library and have tableselect and media library depend on it.
Comment #7
quironRe-rolled to 8.8.x
Comment #8
quironSorry, the previous re-rolled patch was wrong. Adding the correct one.
Comment #9
quironMoved the new JS code to an own library for the checkbox. So renamed JS files to 'checkbox' instead of the generic 'drupal-theme' and make tableselect and media_library view depending on it.
Comment #10
quironComment #11
lauriii@nod_ confirmed on Slack that we can remove the subsystem maintainer review tag based on #5.
Comment #12
lauriiiThis change needs a change record. Drupal.org documentation on how to write a change record.
Comment #13
quironCreated a change record draft: https://www.drupal.org/node/3061281
Comment #14
lauriiiIt seems like we have a few more instances where checkbox is being rendered in JavaScript the old way that should be converted. The files I could find are
user.permissions.es6.js
andsimpletest.js
.Comment #15
quironI will work on it today.
Comment #16
quironImplementing @lauriii's feedback
Comment #17
rosinegrean CreditAttribution: rosinegrean at PitechPlus commentedComment #18
lauriiiCould use a review from a JavaScript maintainer.
Comment #19
Wim Leersform-checkbox
class to ensure the exact same markup is still generated, which is certainly fine (even if said class does not exist in the theme's override of the markup). That's why I'm confident to remove the tag. The only addition is that it's removingComment #20
Wim LeersComment #21
lauriiiDiscussed this issue with @alexpott since I was concerned about the lack of label support. This is needed by
Drupal.behaviors.MediaLibrarySelectAll
.Since this issue already helps us make meaningful progress, and label support could be added without breaking BC in a follow-up, we agreed on the following steps:
Comment #22
lauriiiOpened #3082598: Add theme function for form labels in JavaScript.
Comment #23
alexpottCommitted 21e024e and pushed to 8.8.x. Thanks!