Skip to content

Commit 4b798ca

Browse files
committed
MAGE-1241 Conditionally apply panels to both standard and dynamic widgets
1 parent 3ce2f64 commit 4b798ca

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

view/frontend/web/js/instantsearch.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,20 @@ define([
205205
return;
206206
}
207207

208-
let widget = instantsearch.widgets[type];
208+
search.addWidgets([this.getConfiguredWidget(instantsearch.widgets[type], config)]);
209+
},
209210

211+
/**
212+
* Return a fully configured widget, panelized (as needed) based on the supplied raw config object
213+
* @param widget
214+
* @param config
215+
*/
216+
getConfiguredWidget(widget, config) {
210217
if (config.panelOptions) {
211218
widget = instantsearch.widgets.panel(config.panelOptions)(widget);
212219
delete config.panelOptions; // facet config attribute only NOT IS widget attribute
213220
}
214-
215-
search.addWidgets([widget(config)]);
221+
return widget(config);
216222
},
217223

218224
/**
@@ -231,11 +237,13 @@ define([
231237
const widget = instantsearch.widgets[type];
232238
// The dynamicWidgets container must be derived at run time
233239
return container => {
234-
const newConfig = {
235-
...raw,
236-
container
237-
};
238-
return widget(newConfig);
240+
return this.getConfiguredWidget(
241+
widget,
242+
{
243+
...raw,
244+
container
245+
}
246+
);
239247
};
240248
})
241249
})

0 commit comments

Comments
 (0)