Hi,

Default value for Region drop-down should be set after adding custom block from particular region place block. Please find attachments and scenario below for clear understanding ::

Scenario:
* On click on place block link for header region as seen @blockd8.png.
* Place block pop-up opens showing all the blocks, on clicking the link +Add custom block as seen @blockAddcustomblock.png, user will be able to create custom block.
* After creating the custom block, user redirects to configure block page for created custom block configuration settings, region default value is not set as seen@block2region.png (default region as to be set as header, because as user wants to create custom block for particular header's region).

regards,
harish B

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

harish b created an issue. See original summary.

harish b’s picture

Version: 8.1.3 » 8.2.x-dev
Assigned: harish b » Unassigned
Manjit.Singh’s picture

Issue tags: +DevDaysMilan
Bojhan’s picture

Issue tags: +Usability
joco_sp’s picture

Assigned: Unassigned » joco_sp
joco_sp’s picture

Here is the fix. Please review it.

Wrong patch. Watch comment #8

joco_sp’s picture

Status: Active » Needs review
joco_sp’s picture

Sorry I uploaded the wrong patch. This is the right patch. Please review it.

Status: Needs review » Needs work

The last submitted patch, 8: preselected_block_region-2754955-8.patch, failed testing.

joco_sp’s picture

Reuploading and testing it.

joco_sp’s picture

Status: Needs work » Needs review
harish b’s picture

Status: Needs review » Needs work

Hi joco_sp,

Reviewed @comment10,
Tested manually,Great Patch Working perfectly. Please do not include extra lines in patch@line no.20@File(core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php).

Changing status to needs work. @joco_sp :: Please update the patch.

Regards,
Harish Bompally

Manjit.Singh’s picture

+++ b/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php
@@ -17,10 +17,15 @@ class BlockContentAddLocalAction extends LocalActionDefault {
   public function getOptions(RouteMatchInterface $route_match) {
     $options = parent::getOptions($route_match);
+
     // If the route specifies a theme, append it to the query string.

I think @Harish is mentioning this line. And as per coding standard, I guess inline commenting does not need the extra line. Please check this. https://www.drupal.org/node/1354

@Harish Please use dreditor in future. It will help you to review the patches.

harish b’s picture

Hi,

@manjit : Thanks for your suggestion. I checked Dreditor, it is very helpful.

@joco_sp :: Please update the patch.

joco_sp’s picture

Thank you for your reviews. I removed the extra line.

harish b’s picture

Status: Needs review » Reviewed & tested by the community

Tested manually, Patch working properly.

Changing status to RTBC.

Regards,
Harish B

webchick’s picture

Status: Reviewed & tested by the community » Needs work

This looks like a great usability improvement. Thanks a lot for working on this.

+        if ($region = \Drupal::request()->query->get('region')) {

Rather than \Drupal::request(), let's use $this->getRequest() (per @effulgentsia), since we should have that context from the form.

Additionally, the test needs a bit more working.

+          $opt = array('plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme);
+          // Region for the url.
+          $url = $this->getUrl();
+          $url_pieces = explode("?", $url);
+          foreach ($url_pieces as $u) {
+            if (strstr($u, 'region=')) {
+              $region = explode('=', $u);
+              $opt['region'] = $region[1];
+            }
+          }
+          $this->assertUrl(\Drupal::url('block.admin_add', $opt, array('absolute' => TRUE)));

It seems like we'd be better off to test the end result (e.g. that the region name is correctly selected by default in the drop-down and/or that the block showed up on the front-end in the correct region) rather than query string argument being passed correctly, which is more testing the routing system than this specific change.

webchick’s picture

Also, tested the patch and can confirm that it works! :)

Manjit.Singh’s picture

changes as suggested in #17. Please verify.

Manjit.Singh’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 19: preselected_block_region-2754955-19.patch, failed testing.

joco_sp’s picture

Hello @webchick. Thank you for reviewing the patch.

I made the changes in BlockContentForm, but I still need to do the corrections in the Test, so I am leaving this in Needs work. I will check it as soon as I get some spare time.
In BlockContentAddLocalAction I used \Drupal::request(), as there is no form created yet. Do you suggest that I do it in some other way or is this ok?

harish b’s picture

Issue tags: +blocks
Manjit.Singh’s picture

Status: Needs work » Needs review

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.

tim.plunkett’s picture

Issue tags: -Blocks-Layouts

Not actively part of the Blocks-Layouts work.

harish b’s picture

Status: Needs review » Fixed

Hi all,

Changes got reflected in 8.3.x-dev, So i need to close this issue.

Thanks all for your reviews.

changing status to Fixed and closing it.

Regards,
Harish B

harish b’s picture

Status: Fixed » Closed (fixed)