Generated with the help of an LLM.
Problem/Motivation
Drupal previously loaded the .fieldgroup border and padding reset on every page through system/base. Core commit fae1be903910 moved the reset to core/drupal.fieldgroup. Relevant change record: system/base split into smaller, conditionally loaded libraries.
CompositeFormElementTrait::preRenderCompositeFormElement() adds the fieldgroup class to fieldset wrappers for radio and checkbox groups without attaching the library. In themes that relied on core's reset, these fieldsets can now show the browser's default border and padding.
Steps to reproduce
- Install Drupal core and use a frontend theme without its own
fieldset border or padding reset. - Add the following element to a Form API form and open the form
on a page using that theme.$form['choice'] = [ '#type' =>'radios', '#title' => $this->t('Choices'), '#options' => ['a' => 'A', 'b' => 'B'], ]; - Inspect the wrapping
fieldset.fieldgroup.form-compositein browser developer tools. On a page where no other element loadscore/drupal.fieldgroup, the browser's default border and padding are visible. The expected result is zero border width and padding, matching the previous.fieldgroupreset. - Repeat with
#typeset tocheckboxes.
Proposed resolution
Attach core/drupal.fieldgroup in CompositeFormElementTrait::preRenderCompositeFormElement() when it adds the fieldgroup class.
Remaining tasks
Add regression coverage for the library attachment and open a merge
request.- Review
- Merge
User interface changes
Restore the border and padding reset on radio and checkbox fieldsets in themes that rely on core's .fieldgroup styling.
Introduced terminology
None.
API changes
None.
Data model changes
None.
Release notes snippet
Not applicable.
Issue fork drupal-3641190
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
Comment #2
thomasdegraaff commentedComment #3
thomasdegraaff commentedConfirmed in Chromium on a clean Drupal 11.4.7 installation using the Minimal profile, core’s Stark theme, and core’s built-in form_test module. Both the radio and checkbox fieldsets had a 2px browser-default border and default padding. The page didn’t load fieldgroup.module.css. After I loaded that stylesheet in the browser, both the border width and padding became 0px.
Comment #4
thomasdegraaff commentedComment #5
thomasdegraaff commentedComment #7
keerthi kumar commentedReviewed MR !17911:
- Code review: The fix in `CompositeFormElementTrait` cleanly attaches `core/drupal.fieldgroup` whenever the `fieldgroup` class is added to composite form elements.
- Test coverage: `ElementTest::testFieldsetWrappers()` validates the regression by asserting `fieldgroup.module.css` is attached on composite radio/checkbox forms.
Comment #8
eelkeblokI cleaned up the issue title and the summary a little. There are some failing tests, so back to Needs work.
Comment #9
eelkeblok