Block settings vertical tabs only have summaries for core conditions

Created on 15 July 2016, about 9 years ago
Updated 2 July 2025, about 1 month ago

The block settings shows a vertical tab for every condition plugin, but only the core ones are handled in Drupal.behaviors.blockSettingsSummary to show a summary.

📌 Task
Status

Active

Version

11.0 🔥

Component

block.module

Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom joachim

    > Summaries are a javascript only implementation, there is no server roundtrip. Whatever we do, there is no way around each condition that wants to display a summary having to provide a javascript snippet for this.

    I don't think that's true. The JS that creates a summary line is completely generic: it just takes the checkbox labels and joins them together:

          function checkboxesSummary(context) {
            const values = [];
            const $checkboxes = $(context).find(
              'input[type="checkbox"]:checked + label',
            );
            const il = $checkboxes.length;
            for (let i = 0; i < il; i++) {
              values.push($($checkboxes[i]).html());
            }
            if (!values.length) {
              values.push(Drupal.t('Not restricted'));
            }
            return values.join(', ');
          }
    

    That would cover most condition plugins in contrib.

    The only thing that needs to be changed would be the JS that decides which vertical tabs to apply the above to:

          $(
            '[data-drupal-selector="edit-visibility-node-type"], [data-drupal-selector="edit-visibility-entity-bundlenode"], [data-drupal-selector="edit-visibility-language"], [data-drupal-selector="edit-visibility-user-role"], [data-drupal-selector="edit-visibility-response-status"]',
          ).drupalSetSummary(checkboxesSummary);
    

    Make it opt-out so more complex conditions that supply their own JS and declare that they're opting out in their plugin definition.

    I call this a bug -- Drupal is meant to be extensible, and this isn't.

  • leymannx Berlin

    I agree and would also vote for bug, given that there's even a place in the condition plugin's code where you provide a dynamic summary to be picked up in this exact vertical tabs place.

Production build 0.71.5 2024