Problem/Motivation
With the Claro theme, when a user clicks on the 'Insert' button on the TwigTemplateForm
form, the template code is inserted; however, the page does not scroll upward. The following error is logged in console:
Uncaught TypeError: Cannot read template_entity_form__template_load.js?v1.x:70 properties of undefined (reading 'top')
Beginning in Claro, Drupal changed the class for the item from form-item-template-code
to form-item--template-code
.
From Drupal 9.5.x:
% grep -R -- "'form-item-' ~ name|clean_class"
./core/profiles/demo_umami/themes/umami/templates/classy/form/form-element.html.twig: 'form-item-' ~ name|clean_class,
./core/modules/system/templates/form-element.html.twig: 'form-item-' ~ name|clean_class,
./core/themes/stable/templates/form/form-element.html.twig: 'form-item-' ~ name|clean_class,
./core/themes/stable9/templates/form/form-element.html.twig: 'form-item-' ~ name|clean_class,
./core/themes/bartik/templates/classy/form/form-element.html.twig: 'form-item-' ~ name|clean_class,
./core/themes/classy/templates/form/form-element.html.twig: 'form-item-' ~ name|clean_class,
./core/themes/seven/templates/classy/form/form-element.html.twig: 'form-item-' ~ name|clean_class,
./core/themes/starterkit_theme/templates/form/form-element.html.twig: 'form-item-' ~ name|clean_class,
% grep -R -- "'form-item--' ~ name|clean_class"
./core/themes/claro/templates/form-element.html.twig: 'form-item--' ~ name|clean_class,
Proposed resolution
Add a custom class to the form item, and target it with JS instead.
Remaining tasks
- Write Patch
- Add test coverage
User interface changes
None.
API changes
None.
Data model changes
None.