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.
Issue #2473951 by Cottser, cilefen, yannickoo, davidhernandez, LewisNyman: Prefix form-required classes with js-
Task
Prefix form-required 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
- Install the Language module
- Navigate
/admin/config/regional/language/add
- Select "Custom language"
- Observe "js-form-required" in the mark up
Beta phase evaluation
Issue category | Task |
---|---|
Issue priority | Normal |
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 |
---|---|---|---|
#30 | drupal-prefix_form_required-2473951-30.patch | 20.61 KB | yannickoo |
#15 | interdiff.txt | 1.58 KB | star-szr |
#15 | prefix_form_required-2473951-15.patch | 12.99 KB | star-szr |
#9 | 2473951-7.patch | 11.41 KB | star-szr |
#7 | interdiff.txt | 727 bytes | star-szr |
Comments
Comment #1
star-szrPatch split from parent issue. I wasn't able to find anything additional by grepping.
Comment #2
LewisNymanI manually tested this patch, and I can't really figure out how this is used in Javascript. I can see the
js-form-required
class added but all Javascript seems to do is add/remove theform-required
class for styling. It doesn't seem to use it for functionality.Can @nod_ confirm?
Comment #3
star-szrAdding suggested commit message.
Comment #4
LewisNymanSave us nod!
Comment #5
nod_@lewis: indeed. I can't see form-required used for JS functionality.
The
form-required
is hardcoded in the states.js file though, that's ok with you? I see it's removed from the default datetime wrapper thing, just asking.Comment #6
LewisNymanOk, thanks for clarifying that. I'm ok with this patch, we can always improve this separation down the road, this is not a good time to get our hands dirty in states.js :)
Comment #7
star-szrSmall docs touch up.
Comment #9
star-szrTwo interdiffs :(
Comment #12
star-szrLooked like an unrelated/random fail.
Comment #13
mortendk CreditAttribution: mortendk as a volunteer commentedworks as expected also in stark
and yes we can fix & pretty up more further down the road.
Comment #15
star-szrA test got added in #980144: Issues with "required, multiple" fields in forms using assertRaw for exact markup. Refactoring to use XPath. The attached test-only patch reverts the bug fix part from #980144: Issues with "required, multiple" fields in forms to prove that the revised test still catches the bug fixed there.
Comment #16
star-szrOkay so the test-only patch has to not use
js-form-required
, it's late :) still fails, should be only 1 fail like on #980144-47: Issues with "required, multiple" fields in forms.Comment #19
star-szrAlright so the test only patches did what they were supposed to. Back to needs review.
Comment #20
cilefen CreditAttribution: cilefen commentedreroll
Comment #21
star-szrTagging for reroll.
Comment #22
cilefen CreditAttribution: cilefen commentedrerolled
Comment #23
davidhernandezThis needed rerolling.
Comment #24
LewisNymanThanks. I manually tested this patch and the JS still kicks in.
Comment #25
alexpottThis seems inconsistent - we're adding both classes in the form API but we're not in the default templates - how come?
Comment #26
star-szrBecause we can only make the differentiation between Classy and default when we're in the theme layer (for practical purposes this means preprocess and templates).
The parent issue shows the plan for Classy vs. core templates.
Edit: also we've been getting patches committed that treat Classy markup differently than markup in this meta…
#2473949: Prefix form-type-* classes with js-
#2473957: Prefix text-* classes with js-
Comment #27
alexpott@Cottser yes but those issue completely removed the class they were changing from core - this issue (and the other) has not managed to do that. Therefore the current patch leaves core very inconsistent wrt to whether the form-required class is there.
Comment #28
star-szr@alexpott thanks! I thnk form-type-* completely removed it but text-* didn't, look at the field plugins.
As I said on #2473945: Prefix form-item classes with js- happy to change course to get this wrapped up :)
Comment #29
LewisNymanNeeds work based on the consensus in #2431671: [meta] Add in js- prefixed classes for separation of JS & CSS functionality
Comment #30
yannickooI have added the
form-required
class back to 3 twig templates :)Comment #31
LewisNymanSimple! Thanks.
Comment #32
alexpottCommitted 01e703d and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.