Problem/Motivation

While generating variable values for theme block processing, template_preprocess_block can delete the value of the block label before the block template can decide what to do with it. It does this based on the value of the 'label_display' flag in the block's configuration. If the flag is off it passes an empty string to the template. Although this might make sense if the only choice for the label is to print or not print the value, it denies the themer the opportunity to print but visually hide the label. The accessibility issue is now being addressed by #2614950: Add option for visually-hidden block titles. But it still means the value is being deleted by the system without giving the themer the option to do something with it. Drupal shouldn't be throwing away user data without telling them.

Proposed resolution

Do not delete the value of configuration.label in template_preprocess_block and pass it thru the 'label' variable and force the template to use configuration.label_display to decide whether to omit, visually hide, or make visible the string.

Remaining tasks

Modify template_preprocess_block to pass the value on intact.
Modify existing core block templates to make the appropriate decisions abut this value.
As far as I can see, existing documentation will not have to be changed.

Since #2614950: Add option for visually-hidden block titles is very active right now I am going to postpone this until that is completed, rather than tripping over each other.

Comments

dcrocks created an issue. See original summary.

dcrocks’s picture

Issue summary: View changes
dcrocks’s picture

The current design impacts the use of a dynamic label for the block as well as the static label from the block configuration.

dcrocks’s picture

How does "BlockStorageUnitTest.php" succeed when it is clear the 2 arrays being compared are not identical?

dcrocks’s picture

Status: Active » Needs review
StatusFileSize
new3.83 KB

Here is a first attempt at a patch.

Status: Needs review » Needs work

The last submitted patch, 5: 2715687-5.patch, failed testing.

dcrocks’s picture

Status: Needs work » Needs review
StatusFileSize
new4.37 KB
new551 bytes

One test assumes label can be empty.

dcrocks’s picture

Title: template_preprocess_block deletes value » make templates use 'displat_label' in consistant manner

Perhaps the issue title is misleading. template_preprocess_block shouldn't be making the decision about this flag before the themer can.

andrewmacpherson’s picture

Title: make templates use 'displat_label' in consistant manner » make templates use 'display_label' in consistant manner
dcrocks’s picture

Title: make templates use 'display_label' in consistant manner » make templates use 'display_label' in consistent manner

Spelling?

andrewmacpherson’s picture

Issue tags: +Accessibility
dcrocks’s picture

Category: Task » Bug report

template_preprocess_block reduces the usability of the 'display_label' flag and removes data that a themer might need. So this is a bug, not a task.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.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.3.x-dev » 8.4.x-dev

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

dcrocks’s picture

Issue summary: View changes
Status: Needs review » Postponed
mgifford’s picture

@dcrocks - what is this postponed on?

dcrocks’s picture

On #2614950: Add option for visually-hidden block titles. I mentioned it in the summary. That is active right now and both touch 'function template_preprocess_block'.

mgifford’s picture

Ahh.. Ok, thanks.

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

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.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.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.

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.

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.

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.

smustgrave’s picture

Status: Postponed » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for reporting this problem. We rely on issue reports like this one to resolve bugs and improve Drupal core.

Since there has been no activity here for over 8 years we are asking if this problem persists on a currently supported version of Drupal. To help, add a comment explaining if the problem still occurs or not. Any extra detail you can provide can help others who experienced this.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Wanted to bump this one more time.