Problem/Motivation

I suggested this feature originally in #2450637: Block page visibility option "Show for the listed pages" does not appear to save for better UX when saving a block's page visibility with a path and the option "Show for the listed pages" selected. As a result of that bug fix, the form then presents a counter-intuitive negate selection if the page textarea input remains empty.

In other words, I can see user confusion if the pages textarea input is left empty ( no paths are added ) and the radio option "Show for the listed pages" is selected. While this radio option translates to FALSE negate condition as opposed, I can see how one might read the settings this block will NOT show any pages b/c no paths are provided.

Proposed resolution

To remove this confusion, I suggest adding #states to the negate form element to show/hide when pages form element is not empty.

Remaining tasks

  1. patch, review, test, etc.
  2. Create/update documentation

User interface changes

  • show/hide block's page visibility negate option as condition if paths are provided or not.

Before


After - empty

After - with path

API changes

None

Comments

jasonawant’s picture

Status: Active » Needs review
StatusFileSize
new711 bytes

Here's a patch for review. Feedback welcomed. Thanks, Jason.

wim leers’s picture

Assigned: jasonawant » tim.plunkett
Issue tags: +Usability
+++ b/core/modules/block/src/BlockForm.php
@@ -252,6 +252,11 @@ protected function buildVisibilityInterface(array $form, FormStateInterface $for
+      $form['request_path']['negate']['#states'] = array(
+        'invisible' => array(
+          ':input[name="visibility[request_path][pages]"]' => array('empty' => TRUE),

Let's use [] instead of array().

Looks great though :)

Assigning to Tim Plunkett for review, to make sure this is the right place to do this.

wim leers’s picture

jasonawant’s picture

Hi,

Thanks for reviewing! Here's another patch using [] instead of array() syntax.

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned
StatusFileSize
new1.13 KB

I think this should be part of the request path condition form always, not just when it is used in the context of blocks.

jasonawant’s picture

Status: Needs review » Needs work

Hi Tim,

I tested this out, it worked great! However, I discovered that negate element may need to be required.

While testing, I entered a value into the pages element, and then I could submit the form without actually selecting a negate option. Thoughts?

Jason.

star-szr’s picture

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.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.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should 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.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

markdc’s picture

Referencing another issue that resolves this by restoring the familiar negate checkbox.

quietone’s picture

Version: 8.9.x-dev » 9.3.x-dev
Issue summary: View changes
Status: Needs work » Needs review
Issue tags: +Bug Smash Initiative, +Needs usability review
StatusFileSize
new33.08 KB
new25.86 KB
new30.94 KB
new1.65 KB

Two weeks ago the Bug Smash triage looked at block visibility issues and this feature request was accidentally included and got a review although not yet documented - I am doing that no. Adding tag.

The review suggested that this issue and #2301625: Incorrect behaviour for block page visibility need a Usability review to decide on what should or should not be done to clarify the 'Pages' section of block visibility. Then work will continue on their recommendations.

I have updated the patch and made before and after screenshots to help that review. Adding tag.

I'll ask in #ux for a review once I finish updating #2301625: Incorrect behaviour for block page visibility .

benjifisher’s picture

Status: Needs review » Closed (duplicate)
Issue tags: -Needs usability review

Usability review

We discussed this issue at #3239070: Drupal Usability Meeting 2021-10-01. That issue has a link to a recording of the meeting.

I am closing this issue as a duplicate of #2301625: Incorrect behaviour for block page visibility, which discusses several different solutions to the same problem that this issue addresses. The usability group preferred one of those solutions to the one here.

Here is one problem with the solution proposed here. Suppose a site administrator wants a block to be shown on every page except three. They might give up on the task, not wanting to type in paths (with wildcards) representing all the other pages. The problem is that, until they start typing, they do not see the "Hide for the listed pages" option.