When Placing a Block on 'Configure Block' page the originally selected region is lost

Created on 5 December 2016, about 8 years ago
Updated 30 March 2024, 9 months ago

Problem/Motivation

When creating a new block via block layout region is not stored.

Steps to reproduce

1) Go to /admin/structure/blocks
2) Use the 'Place Block' function next to a region, for example the 'Sidebar Second'.
3) Choose 'add custom block'
4) On the 'Configure Block'-page the region you've selected on step #2 is not selected.

Proposed resolution

Use a URL parameter to remember/set the region like we do for theme

Remaining tasks

User interface changes

When creating a new block the region will be remembered.

API changes

NA

Data model changes

NA

Release notes snippet

NA

🐛 Bug report
Status

Fixed

Version

10.3

Component
Block content 

Last updated 17 days ago

Created by

🇧🇪Belgium Peter van den Heuvel

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • 🇺🇸United States smustgrave

    Started back at #31

    Updated the comment slightly
    Added the current route to the LocalActionDefault

  • 🇺🇸United States smustgrave

    More convinced we will need a trigger_error :(

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,184 pass, 2 fail
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,208 pass
  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States smustgrave

    Tested patch #50 following steps in issue summary and it resolves the issue.

    Still think we will need a trigger_error but maybe the committer will surprise me.

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,284 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,301 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,303 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,301 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,363 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,367 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,368 pass
  • Status changed to Needs work over 1 year ago
  • 🇳🇿New Zealand quietone

    Doing RTBC triage.

    The first thing I notice is that the issue summary is incomplete and the steps to reproduce are out of date. And since this is making a change to the user interface there should be before and after screenshots. However, maybe manual testing here is fine.

    I read the comments. I agree with #24 that this is a nice usability improvement. The changes asked for in #24 appear to have been done. In #42 there should be an explanation for why the current route is added to LocalActionDefault and that should be in the proposed resolution as well. And a reminder that anyone who works on a patch should ask for reviews and someone else to set the issue to RTBC.

    I then looked at the patch.

    1. +++ b/core/modules/block/src/Controller/BlockLibraryController.php
      @@ -104,6 +104,14 @@ public function listBlocks(Request $request, $theme) {
      +    // Add url route parameters to provide correct region setting
      +    // after creation.
      

      Needs to be wrapped to 80 columns.

    2. +++ b/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php
      @@ -20,6 +20,12 @@ public function getOptions(RouteMatchInterface $route_match) {
      +    // If the current request has a region query parameter.
      

      This isn't a complete sentence.

    3. +++ b/core/modules/block_content/tests/src/Functional/BlockContentListTest.php
      @@ -69,6 +69,22 @@ protected function setUp(): void {
      +   * Tests that region value is retained when we create new block.
      

      This can be simpler. "Tests the region value when a new block is saved."

    4. +++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php
      @@ -37,11 +44,14 @@ class LocalActionDefault extends PluginBase implements LocalActionInterface, Con
      +  public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteProviderInterface $route_provider, Request $request) {
      

      See policy for adding constructor arguments . Although my later testing questions whether these changes are needed.

    5. +++ b/core/modules/block_content/tests/src/Functional/BlockContentListTest.php
      @@ -69,6 +69,22 @@ protected function setUp(): void {
      +      'info[0][value]' => $this->randomString(),
      

      Since this is testing placement and not the value can we skip generating a random value and just use, say, 'foo'.

    I then tested on a fresh install of Drupal 10.1x, standard install. First, I confirmed the problem using the steps in the IS. The I applied the patch and confirmed the fix. I then removed the changes to the menu system (core/modules/menu_ui/src/Plugin/Menu/LocalAction/MenuLinkAdd.php and core/modules/menu_ui/src/Plugin/Menu/LocalAction/MenuLinkAdd.php), cleared cached and retested. The fix was still working but the new test was failing. That needs to be looked into. I didn't look further myself.

    So, back to NW for comment changes and then a question about the changes to the menu system.

  • Assigned to nitin_lama
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,372 pass
  • 🇮🇳India nitin_lama India

    Addressed #54 changes but not sure of the cause of the failed tests. For pointer 4, we can remove the unused class object but are unsure of its original purpose. Updated patch. Please review.

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    Issue summary needs to be updated

    and #54.4 hasn't been done.

  • 🇺🇸United States smustgrave

    Hiding patches and converted to MR.

  • Pipeline finished with Success
    about 1 year ago
    Total: 784s
    #55825
  • Status changed to Needs review about 1 year ago
  • 🇺🇸United States smustgrave

    @quietone the request is used to get the query parameter which can't get from route_match. To get around that we would probably have to update the url to include region also. That seemed like the least desirable approach

  • Status changed to Needs work about 1 year ago
  • 🇳🇿New Zealand quietone

    @smustgrave, thanks. I don't know enough about this so I will leave this for others to RTBC.

    The conversion to MR lost a change, I have commented in the MR.

  • Status changed to Needs review about 1 year ago
  • Pipeline finished with Success
    about 1 year ago
    Total: 539s
    #57495
  • Status changed to RTBC about 1 year ago
  • 🇮🇳India Nitin shrivastava

    @smustgrave
    The issue has been resolved following the patch in MR #5562. When creating a custom block within the region, it displays correctly in the drop-down menu, automatically selecting the respective region
    Thanks !

    After Implementation

  • Nitpick: Is it normal for `url` to be lower-case in comments? It’s an acronym.

    Neither my comment nor the screenshot review above should be credited.

  • Status changed to Needs work about 1 year ago
  • The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Left a review

  • Pipeline finished with Failed
    about 1 year ago
    Total: 197s
    #62080
  • Pipeline finished with Success
    about 1 year ago
    #62088
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India mohit_aghera Rajkot

    @larowlan Addressed all 3 issues.
    Tests are green now.

  • Status changed to RTBC about 1 year ago
  • 🇺🇸United States smustgrave

    Resolved all the threads fixed by @mohit_aghera.

    Rebased the MR as there was a merge conflict.

    Retested by going through block layout > place block into content region > custom block > verified region is saved.

  • Pipeline finished with Success
    about 1 year ago
    Total: 661s
    #62163
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Updating issue credits

  • Status changed to Needs work 12 months ago
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Left some comments on the MR to simplify this

  • Status changed to Needs review 12 months ago
  • 🇺🇸United States smustgrave

    Addressed feedback.

  • Pipeline finished with Failed
    12 months ago
    Total: 202s
    #68024
  • Pipeline finished with Success
    12 months ago
    Total: 630s
    #68099
  • Pipeline finished with Success
    10 months ago
    Total: 497s
    #107433
  • Pipeline finished with Failed
    10 months ago
    Total: 177s
    #107442
  • Status changed to Needs work 10 months ago
  • The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

  • Status changed to Needs review 10 months ago
  • 🇺🇸United States smustgrave

    Fixed

  • Pipeline finished with Success
    10 months ago
    Total: 489s
    #107462
  • Status changed to Needs work 10 months ago
  • The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

  • Pipeline finished with Canceled
    10 months ago
    Total: 237s
    #112950
  • Pipeline finished with Failed
    10 months ago
    Total: 116s
    #112959
  • Pipeline finished with Success
    10 months ago
    #112961
  • Status changed to Needs review 10 months ago
  • 🇺🇸United States smustgrave

    Rebased

  • First commit to issue fork.
  • Status changed to RTBC 10 months ago
  • 🇦🇺Australia acbramley

    Test only failed as expected. Looks good to go!

  • Pipeline finished with Success
    10 months ago
    Total: 548s
    #113358
  • 🇺🇸United States smustgrave

    Thanks @acbramley!

  • Pipeline finished with Canceled
    9 months ago
    Total: 386s
    #120999
  • Pipeline finished with Success
    9 months ago
    Total: 488s
    #121005
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Committed and pushed 1f94e17f9f to 11.x and a0138ae5ef to 10.3.x. Thanks!

    • alexpott committed a0138ae5 on 10.3.x
      Issue #2833116 by smustgrave, mohit_aghera, Ratan Priya, _pratik_, _shY...
  • Status changed to Fixed 9 months ago
    • alexpott committed 1f94e17f on 11.x
      Issue #2833116 by smustgrave, mohit_aghera, Ratan Priya, _pratik_, _shY...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024