When editing a node, Drupal shows "Promotion options" as a tab, with a settings summary beneath - see attached image.

In bootstrap theme, with "Use the administration theme when editing or creating content" enabled, the settings summary is missing.

The problem comes from Plugin\PreprocessFormElement code commented "Place single checkboxes and radios in the label field." This is a modification that is required in Bootstrap for checkboxes and radios to function properly.

However, this modification means that node.es6.js fails to find the element where it expects.

In this case, simply using .closest('label') instead of .next('label') will work for all.

        if ($optionsContext.find('input').is(':checked')) {
          $optionsContext.find('input:checked').closest('label').each(function () {
            vals.push(Drupal.checkPlain($.trim($(this).text())));
          });
          return vals.join(', ');
        }

Comments

AdamPS created an issue. See original summary.

markhalliwell’s picture

Title: Checkbox placed in label field breaks Core "Promotion options" settings summary » Checkboxes that are placed in labels break "Promotion options" settings summary
Project: Bootstrap » Drupal core
Version: 8.x-3.x-dev » 8.5.x-dev
Component: Code » node system
Priority: Normal » Minor
Issue summary: View changes
Issue tags: +JavaScript

This is a rather trivial bug IMO, but it should be fixed upstream... not hacked in contrib.

There is a lot of JS code still in core that expects a certain structure. In this case, simply using .closest('label') instead of .next('label') will work for all.

That being said, it should probably just get the parent .form-item element and then grab all the text inside using .text() (might not work if the element has an individual description though...). Targeting any specific DOM elements or expecting a certain DOM hierarchy structure in JS is a big no-no.

I've updated the issue summary.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

bhanuprakashnani’s picture

Assigned: Unassigned » bhanuprakashnani
droplet’s picture

This is the known issue if it's only a bug for the particular theme.

we have a list of things, and going to refactoring:
#2871619: Refactoring content_type.js

In another word: the CORE script doesn't handle different code patterns than the CORE (form API) one.

bhanuprakashnani’s picture

Status: Active » Needs review
StatusFileSize
new702 bytes

@AdamPS

Attached a fresh patch. please review

markhalliwell’s picture

Status: Needs review » Needs work

the CORE script doesn't handle different code patterns

Targeting DOM elements and expecting a specific DOM hierarchy is an anti-pattern . Contrib has the ability to alter markup. I think what you meant to say is that core [maintainers] don't like making changes against these inherited/existing anti-patterns; especially when other frameworks show just how broken they truly are.

---

@bhanuprakashnani, you don't edit the compiled .js file, you must edit the corresponding .es6.js file.

droplet’s picture

@markcarver,

I think what you meant to say is that core [maintainers] don't like making changes

I meant this is an expected behavior and we going to (I suggest to) improve it for each instance at once rather than chop them into few issues with a different workaround. During the refactoring, I prefer a quick fix from the particular theme that breaks the UI but I'm not against to any good patch in this issue thread. So I have not marked it as duplicated.

`closest` is only worked on this issue instance. And this is still a `specific DOM hierarchy`. If we accept `Contrib has the ability to alter markup` (code patterns in my, @droplet's term) as the reason to make this fix, it's far from a good patch. The altered pattern outside the box of `closest` will break again.

We also need some Tests to move the patch forward.

Thanks.

chiranjeeb2410’s picture

Status: Needs work » Needs review
StatusFileSize
new568 bytes

Uploaded new patch with change suggested by in #7 in .es6.js file.
Hope it goes green!

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

adamps’s picture

Priority: Minor » Normal
Status: Needs review » Reviewed & tested by the community

I don't really understand all the discussion in #7-#8. However this patch does indeed fix the bug, thanks chiranjeeb2410.

I fixed the priority field value to match the official description of how it should be used:

Minor priority is most often used for cosmetic issues that do not inhibit the functionality or main purpose of the project.

Examples of minor bugs: An incorrect class reference only in a comment.
...
Most issues are considered normal.

This bug causes a misleading report of the current promotion options, and the user will not be aware of the error unless they actually click to expand the tab.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 9: 2922822-9.patch, failed testing. View results

adamps’s picture

Status: Needs work » Needs review
StatusFileSize
new496 bytes

Reroll

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
Issue tags: -JavaScript +JavaScript
StatusFileSize
new144 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture

Status: Needs work » Postponed (maintainer needs more info)

Is this still an issue that the bootstrap theme needs to work around? Looks like we're still using .next() https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/node/...

acbramley’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

I installed the Bootstrap theme and set it as the admin theme and tested the summary fieldsets on node/add and wasn't able to reproduce this issue (they looked fine), although it's hard to say from the limited information in the IS and provided screenshots.

I'm closing this now as cannot reproduce but please feel free to reopen it with more thorough steps if it's still an issue.

Crediting people here that attempted to fix this.