From 5a5f40c6c9c80b4599f6cbe0f59ead8d1daaabcd Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Thu, 31 Oct 2024 15:18:47 -0300 Subject: [PATCH] Filters enabled view modes to assure they are registered. --- src/views/gutenberg-blocks/blocks/faceted-search/theme.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js index 5b9b05ccd..79cd07b28 100644 --- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js +++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js @@ -81,9 +81,13 @@ export default (element) => { // At first, we consider that all registered view modes are included. let possibleViewModes = registeredViewModes; - if ( getDataAttribute(blockElement, 'enabled-view-modes') != undefined ) + if ( getDataAttribute(blockElement, 'enabled-view-modes') != undefined ) { possibleViewModes = getDataAttribute(blockElement, 'enabled-view-modes').split(','); + // Filter out the view modes that are not registered + possibleViewModes = possibleViewModes.filter(viewModeSlug => registeredViewModes.indexOf(viewModeSlug) >= 0); + } + // View Mode settings let possibleDefaultViewMode = 'masonry'; if ( getDataAttribute(blockElement, 'default-view-mode') != undefined )