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.
Task
Prefix form-item classes with js- to separate classes needed for JavaScript functionality from those used for styling and make it clear which classes can safely be removed without breaking JavaScript functionality.
Remaining tasks
- Patch
- Patch review
- Manual testing
Steps to test
- Navigate to
admin/structure/types/manage/article/fields/add-field
- Test that the machine name functionality still works
Beta phase evaluation
Issue category | Bug report, there is currently a class missing from the non-Classy text-format-wrapper.html.twig. |
---|---|
Unfrozen changes | Unfrozen because it mostly just affects templates and JS which are not frozen. |
Prioritized changes | The main goal of this issue is to improve themer experience and arguably it reduces fragility where JavaScript and markup intersect. |
Disruption | Shouldn't be too disruptive as it is mostly affecting CSS classes that are added to markup. Themes extending Classy will only have classes added. Themes not extending Classy will have classes removed but they can be added back via template overrides. |
User interface changes
None for themes extending Classy. Possible visual changes for other themes.
API changes
n/a
Comment | File | Size | Author |
---|---|---|---|
#38 | prefix_form_item-2473945-38.patch | 20.09 KB | davidhernandez |
#35 | prefix_form_item-2473945-35.patch | 19.54 KB | rachel_norfolk |
#34 | prefix_form_item-2473945-34.patch | 20.09 KB | rachel_norfolk |
#10 | 2473945-form-item-split-10.patch | 20.41 KB | emma.maria |
#6 | 2473945-form-item-split.patch | 20.3 KB | star-szr |
Comments
Comment #1
star-szrInitial patch split from the parent, some additional changes from grepping, and interdiff between the two.
Comment #3
LewisNymanI manually tested the patch and it works. I also grepped and couldn't find any other changes.
I think here we could also just test for the functional class as well?
Comment #4
star-szrYeah IMO that XPath shouldn't care that much about the classes. Updating that in a separate issue would make 2-3 of these patches smaller.
Comment #5
star-szrHere's that issue: #2474107: Make OptionsWidgetsTest::testEmptyValue() care less about markup
Comment #6
star-szrReuploading the initially split patch after #2474107: Make OptionsWidgetsTest::testEmptyValue() care less about markup was committed.
Also these issues all need commit credits I'm realizing!
Comment #7
star-szrAdding suggested commit message.
Comment #8
LewisNymanOk in that case we can fix the test in a followup. I knight this issue RTBC.
Comment #10
emma.mariaI rerolled the patch.
Comment #11
star-szr@LewisNyman already fixed :D #2474107: Make OptionsWidgetsTest::testEmptyValue() care less about markup
Comment #12
LewisNymanGreat! Thanks.
Comment #13
star-szrChanging to bug report because non-Classy text-format-wrapper.html.twig is currently missing a class that is used in JS. Tweaked beta evaluation accordingly.
Comment #15
star-szrAnother reroll, just a small conflict in core's form-element.html.twig.
Comment #16
star-szrRerolling because #2473953: Prefix form-submit classes with js- got in :)
Comment #17
star-szrTagging for reroll.
Comment #18
cilefen CreditAttribution: cilefen commentedrerolled
Comment #19
davidhernandezJust making a note that this one still applies cleanly.
Comment #20
LewisNymanNice work everyone. This is identical to the pervious patch I RTBC'd
Comment #21
alexpotthuh?
Here we add...
Here we are taking away. I think all the changes from form-item => js-form-item should instead by additions to be consistent with the rest of the patch.
Comment #22
alexpottComment #23
star-szrI think my comment on #2473951-26: Prefix form-required classes with js- applies here as well, but I'd be fine with changing gears and doing additions only in the interests of getting this and similar issues in :)
And more specifically this is the only really problematic part I can see because we shouldn't be removing classes from Classy at this point.
Comment #24
axe312 CreditAttribution: axe312 at Wunder commentedi am working on this
Comment #25
axe312 CreditAttribution: axe312 at Wunder commentedI added the missing form-item classes and removed the change to the text-format-wrapper which might be added accidentally in the last patch.
Also the patch is now applying to most current dev.
Comment #27
LewisNymanComment #28
yannickooComment #29
LewisNymanOk great. Thanks for working on this.
Comment #30
alexpottThis is about
form-item
we shouldn't be removingtext-format-wrapper
here.Comment #31
yannickooI have added the
text-format-wrapper
back but I'm kinda confused why there that class is missing incore/modules/filter/templates/text-format-wrapper.html.twig
.Comment #32
davidhernandez@yannickoo, thetext-format-wrapper class isn't needed in the core version of the template. It is in the Classy version.
I don't understand why these form-item classes are being added here. All the patches in this issue have this. Am I missing something?
Comment #33
alexpott@davidhernandez I think this javascript was broken by a previous over-zealous removal of classes. This one #2349677: Copy filter templates to Classy
Comment #34
rachel_norfolkI'm kinda hoping I've got this re-roll correct...
Comment #35
rachel_norfolkI have looked into the comments at #34 and can't find any need for the form-item and js-form-item classes to appear on the wrappers, as @davidhernandez mentions. The actual form items within that group contain the classes, anyway.
I wasn't able to work out the issue at #33 and maybe I'm just not seeing a problem in my own manual testing?
Comment #36
star-szrThanks @rachel_norfolk :)
Based on #33 it sounds like this should stay and a js-form-item be added, and these classes also be added to the core template. I don't know how to manually test that JS though.
Comment #37
LewisNymanSounds like this needs work to add these classes back in.
Comment #38
davidhernandezAdded the classes back.
Comment #39
akalata CreditAttribution: akalata commentedCurrently doing some in-depth manual testing.
Comment #40
akalata CreditAttribution: akalata commentedI've manually tested the changes in the following files:
Javacript
core/misc/machine-name.js via admin/structure/types/manage/article/fields/add-field
core/modules/filter/filter.filter_html.admin.js via node/add/page
core/modules/locale/locale.admin.js via admin/config/regional/translate
Modules/System/other default using Stark as admin theme
core/modules/filter/templates/text-format-wrapper.html.twig via node/add/page
core/modules/system/form-element.html.twig via admin/structure/types/manage/article/fields/add-field
Classy as admin theme
core/themes/classy/templates/content-edit/text-format-wrapper.html.twig via node/add/page
core/themes/classy/templates/form/form-element.html.twig via admin/structure/types/manage/article/fields/add-field
I was able to partially test the following:
core/misc/states.js I tested the
:visible
, but could not find a usage of:required
or:disabled
as actual state changes -- I'm thinking this is what @cottser meant in #36?core/modules/system/fieldset.html.twig and core/themes/classy/templates/form/fieldset.html.twig The html changes were good (tested at search/node), but I could not find a collapsing fieldset in order to test related javascript (that I'm assuming exists).
core/modules/system/templates/field-multiple-value-form.html.twig
and core/themes/classy/templates/form/field-multiple.value-form.html.twig The html changes were good (tested by adding a multi-value text field), but I'm not sure that any javascript was updated so that it actually is looking for this class. (I removed .form-item and it worked, so maybe it's not using either class?)
I also tested the html in about half the files listed below, but I have to ask does it really make sense to add the js- to these markup wrappers? I know they're being added everywhere else for consistency via
form-element.html.twig
; if people think they should stay I can finish up that testing for good measure.Comment #41
jaxxed CreditAttribution: jaxxed at Wunder commentedShould we also look at this from the other side: what JS calls are looking for .form-item, when they could/should be looking for .js-form-item?
Comment #42
davidhernandez@jaxxed, yes, the patch should update any JS that is looking for the class. It looks like in your txt file you are finding classes that being with form-item-*. There is a separate issue for that. #2473947: Prefix form-item-* classes with js-
This issue is just for the exact "form-item" classes.
Comment #43
LewisNyman@jaxxed Yep, the javascript should be calling
.js-form-item
instead of.form-item
. It looks like your grep only turned up classes that start withform-item-*
. Those are being covered in #2473947: Prefix form-item-* classes with js-. Maybe that is a good one to review next.Setting this to RTBC.
Comment #44
alexpottCommitted 44e0f2f and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.