Skip to content
Snippets Groups Projects

Issue #3223048: Layout builder filter leaves blank space

Closed Issue #3223048: Layout builder filter leaves blank space
1 unresolved thread
1 unresolved thread
Files
3
@@ -32,7 +32,7 @@
* The jQuery event for the keyup event that triggered the filter.
*/
const filterBlockList = (e) => {
const query = $(e.target).val().toLowerCase();
const query = e.target.value.toLowerCase();
/**
* Shows or hides the block entry based on the query.
@@ -43,9 +43,15 @@
* The link to add the block.
*/
const toggleBlockEntry = (index, link) => {
const $link = $(link);
const textMatch = $link.text().toLowerCase().indexOf(query) !== -1;
$link.toggle(textMatch);
const linkJquery = $(link);
const textMatch =
link.textContent.toLowerCase().indexOf(query) !== -1;
// Checks if a category is currently hidden. Toggles the category on if so.
if (linkJquery.closest('.js-layout-builder-category').is(':hidden')) {
linkJquery.closest('.js-layout-builder-category').show();
}
// Toggle the li tag of the matching link.
linkJquery.parent().toggle(textMatch);
};
// Filter if the length of the query is at least 2 characters.
@@ -82,15 +88,17 @@
.find('.js-layout-builder-category[remember-closed]')
.removeAttr('open')
.removeAttr('remember-closed');
// Show all categories since filter is turned off.
$categories.find('.js-layout-builder-category').show();
$filterLinks.show();
// Show all li tags since filter is turned off.
$filterLinks.parent().show();
Please register or sign in to reply
announce(Drupal.t('All available blocks are listed.'));
}
};
$(
once('block-filter-text', 'input.js-layout-builder-filter', context),
).on('keyup', debounce(filterBlockList, 200));
).on('input', debounce(filterBlockList, 200));
},
};
Loading