Problem/Motivation

- Go to admin/structure/block and use the "Place block" button
- The "Place block" dialog provides a filter "Filter by block name"

When using facets, I know I want to use a "Facets" block. When I start typing "facet", I don't get any results.

Steps to reproduce

Proposed resolution

I think, we should change the filter to "Filter by black name or category".

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-2711735

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dasjo created an issue. See original summary.

dasjo’s picture

Issue tags: +Usability
dawehner’s picture

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.

kthull’s picture

Ha! This is exactly the same use case that brought me looking to see if there is already an issue for this.

tetranz’s picture

Assigned: Unassigned » tetranz

Working on it ...

tetranz’s picture

Status: Active » Needs review
FileSize
4.82 KB
32.35 KB
53.92 KB
30.53 KB

Filter by name

Filter by category

Filter by both

tetranz’s picture

hmm ... I guess a single text box that searches both would be better. Doing that now.

tetranz’s picture

The last submitted patch, 8: block-filter-2711735-8.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 10: block-filter-2711735-10.patch, failed testing.

tim.plunkett’s picture

Combining it looks way better!

+++ b/core/modules/block/js/block.admin.js
@@ -49,8 +52,15 @@
           var $row = $label.parent().parent();
...
+            var $category = $label.parent().parent().find('div.block-filter-category-source');

I think this could be
var $category = $row.find('.block-filter-category-source');


The new div around the category is causing some overly-specific tests to fail.
For example:
\Drupal\block\Tests\Views\DisplayBlockTest::testBlockCategory
$pattern = '//tr[.//td[text()=:category] and .//td//a[contains(@href, :href)]]';

tetranz’s picture

Status: Needs work » Needs review
FileSize
4.91 KB
2.48 KB

Thanks Tim.

Dinesh18’s picture

Verified the interdiff.txt. It implements all the comments mentioned in #13.
+1 to RTBC.

tetranz’s picture

Assigned: tetranz » Unassigned

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.

ranjith_kumar_k_u’s picture

Re-rolled for 9.2

sonam.chaturvedi’s picture

Assigned: Unassigned » sonam.chaturvedi
sonam.chaturvedi’s picture

Assigned: sonam.chaturvedi » Unassigned
FileSize
48.47 KB
39.12 KB
43.22 KB
40.49 KB

Verified and tested patch#24. Patch applied successfully.

Testing Steps:
1. Go to Admin > Structure > Block Layout
2. Click on "Place block" button
3. Search block by category. For ex. core
4. Check no result is found
5. Now apply the patch
6. Again, click on "Place block" button
7. Search block by "block name"
8. Verify correct result is displayed
9. Search block by "block category"
10. Verify correct result is displayed
11. Search block by both "block name and category"
12. Verify correct result is displayed

Testing Results:
Block are searched and filtered correctly based on name, category and both

Before patch:
before patch24

After patch:
Filter by name
filter by name

Filter by category
filter by category

Filter by both
filter by both

sonam.chaturvedi’s picture

Status: Needs review » Reviewed & tested by the community
tim.plunkett’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/block/js/block.admin.js
@@ -18,8 +18,15 @@
-          var textMatch = $label.text().toLowerCase().indexOf(query) !== -1;
-          $row.toggle(textMatch);
+          var labelMatch = $label.text().toLowerCase().indexOf(query) !== -1;
+          var categoryMatch = false;
+
+          if (!labelMatch) {
+            var $category = $row.find('div.block-filter-category-source');
+            categoryMatch = $category.text().toLowerCase().indexOf(query) !== -1;
+          }
+
+          $row.toggle(labelMatch || categoryMatch);
         }

As it says at the top of this file:

DO NOT EDIT THIS FILE

You have to edit the block.admin.es6.js file and then compile this one.

vakulrai’s picture

Status: Needs work » Needs review
FileSize
5.58 KB

@tim.plunkett , I have updated the patch as per your inputs. The patch include changes to .es6.js and .js files.

Please review.

KapilV’s picture

Assigned: Unassigned » KapilV
KapilV’s picture

KapilV’s picture

FileSize
1000 bytes
tim.plunkett’s picture

Can't use const and then reassign it like that.
I'm not sure that let categoryMatch = false; is the best way to do this, but at least it's valid JS...

mrweiner’s picture

Just taking a quick look at the code without actually testing, some other ways you could keep categoryMatch as a const:

const categoryMatch = (() => {
  if(labelMatch) {
    return false;
  }
        
  const $category = $row.find('div.block-filter-category-source');
  return $category.text().toLowerCase().indexOf(query) !== -1;
})();

// or
const $category = $row.find('div.block-filter-category-source');
const categoryMatch = labelMatch ? false : $category.text().toLowerCase().indexOf(query) !== -1;

// or
const categoryMatch = labelMatch ? false : $row.find('div.block-filter-category-source').text().toLowerCase().indexOf(query) !== -1;

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.

vikashsoni’s picture

Patch not applying in drupal-9.3.x-dev
giving error while applying the patch

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.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
150 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

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

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.