Problem/Motivation

When adding block through the Layout builder, the 'Filter by block name' filter doesn't seem to find any results.
This is tested with Drupal core 9.4.5 on simplytest.me

See attached screenshots for example.

Issue fork drupal-3308658

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:

Comments

yivanov created an issue. See original summary.

cassioalmeida made their first commit to this issue’s fork.

cassioalmeida’s picture

I faced this issue today on multiple sites.
Based on this issue (https://github.com/jquery/jquery/issues/5098) the has selector has a bug on Chrome due to new CSS selectors.
I changed the code to use a for each instead of a pure CSS selector.

cassioalmeida’s picture

Status: Active » Needs review
carolpettirossi’s picture

Status: Needs review » Reviewed & tested by the community

RTBC. The "Merge request !2744" solved the issue for me.

I tested the patch without applying any other core patch, and the reported issue is gone.

As a side note, I'm using it in combination with patch #23 provided on 3103506 and it works as expected too.

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests, +Blocks-Layouts

This should have automated test coverage.

leo liao’s picture

StatusFileSize
new1.73 KB

Had the same problem in 9.3

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

cassioalmeida’s picture

Status: Needs work » Needs review

Does not the test Drupal\Tests\layout_builder\FunctionalJavascript\BlockFilterTest already check for it?
I'm considering this a refactor, and the test ensures it still works.
Here are the test results (all passing) - https://dispatcher.drupalci.org/job/drupal_patches/147661/testReport/Layout_builder/

_utsavsharma’s picture

StatusFileSize
new1.79 KB
new1.77 KB

Tried to fix CCF for #8.
Please review.

shani maurya’s picture

Version: 9.5.x-dev » 9.4.x-dev
StatusFileSize
new1.79 KB

Adding Patch for 9.4.3 core version

shani maurya’s picture

Version: 9.4.x-dev » 9.5.x-dev

Status: Needs review » Needs work

The last submitted patch, 12: filter_by_block_3308658.patch, failed testing. View results

cassioalmeida’s picture

Version: 9.5.x-dev » 9.4.x-dev
Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new2.52 KB

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.

crzdev’s picture

Into D10 (10.0.7) version & just adding "$build['#type'] = 'container';" to choose block customized controlled (has no type by default, just children items, calling to parent method to get original structure) seems working correctly (seems js context "const $categories = $('.js-layout-builder-categories', context);" detect nothing, 0 length, if that selector is the first level of context). Maybe is easier to add into original controller if that works too for D9.5 version or modify js to avoid that extra tag (not checked for D9, js seems different). Scenario: layout builder lock + layout builder restrictions & customized choose block controller.

drupalninja99’s picture

I am still having this issue in D10

digitalfrontiersmedia’s picture

@CRZDEV, Are you using the Layout Builder Modal module? If so, the context returned is different from off-canvas context and is one level lower than what is returned with off-canvas. "$('.js-layout-builder-categories', context)" returns 0 length in this situation. There could be other alters, etc. type of configurations that could result the same. I had to duplicate layout-builder.js in a custom library since Core patch in our case wasn't an easy option. The custom version used "$(context).parent()" instead of "context".

sahilgidwani’s picture

StatusFileSize
new700 bytes

Adding patch for v10.1

_utsavsharma’s picture

StatusFileSize
new910 bytes
new738 bytes

Fixed failures in #20.

crzdev’s picture

@DigitalFrontiersMedia Not exactly that module but yeah, a modal provided by VLSuite, change that you suggest also has sense in that context. In any case not sure if it should work as intuition suggests, maybe it should, main context selector is also loaded by ajax.

johnpitcairn’s picture

Version: 9.4.x-dev » 11.x-dev
phjou’s picture

I don't know if it is related because the "Filter by block name" seems to work on Chrome but on Firefox, I do not get any results and the feature brings the CPU usage to 100% and ultimately the browser tab ends up crashing.

danielveza’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce, +Bug Smash Initiative

Hey all,

I've been testing this with a fresh install of D11 and the block filter is working correctly in all of my tests.

Steps I've taken:

  1. Install fresh D11 standard site
  2. Enable LB & overrides on the article content type
  3. Create an article and go to the layout page for it
  4. Click add block
  5. Try filter by "ID", and verify the ID, Revision ID and User ID blocks are shown and all other blocks are filtered out.

Do people have other LB modules that may be causing issues here? For example I see that Layout Builder browser has had various issues related to this over the years.

Could we please get some steps to replicate with just Drupal core?

carolpettirossi’s picture

StatusFileSize
new3.97 MB

I couldn't reproduce the issue on Drupal 10.2.4

1. Created a D10 instance on simplytest.me
2. Enabled LB & overrides on the basic page content type
3. Created a basic page
4. Clicked on Layout tab
5. Click to "add block"
6. Try filter by an invalid block name and then fix the typo

Result: working as expected listing the available blocks.

screencast showing test/QA on D10

cassioalmeida’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Based on the last comments, it seems this is not related to Layout Builder but a combination of it with other modules, such as Layout Builder Modal.

If this is the case, I'd recommend closing this issue.

r_cheh’s picture

The layout builder block search wasn't working because of front theme on the layout edit page, the solution was found - the script tried to hide the parent element of the link but we needed to hide just the links. For me it works, maybe it also will be useful for someone.