Skip to content

Commit 5eca7a0

Browse files
authored
Enrichment bug fixes (#35)
1 parent 8928f90 commit 5eca7a0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

blocks/enrichment/enrichment.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ export default async function decorate(block) {
1313
}
1414

1515
if (type === 'category') {
16-
const categoryId = document.querySelector('.block.product-list-page')?.dataset?.category;
16+
const plpBlock = document.querySelector('.block.product-list-page');
17+
if (!plpBlock) return;
18+
19+
let categoryId = plpBlock.dataset?.category;
20+
if (!categoryId) {
21+
categoryId = readBlockConfig(plpBlock).category;
22+
}
1723
if (!categoryId) return;
1824
filters.categories = categoryId;
1925
}
@@ -36,7 +42,8 @@ export default async function decorate(block) {
3642
const section = fragment.querySelector(':scope .section');
3743
if (section) {
3844
block.closest('.section').classList.add(...section.classList);
39-
block.closest('.section').append(...section.childNodes);
45+
const wrapper = block.closest('.enrichment-wrapper');
46+
section.childNodes.forEach((child) => wrapper.parentNode.insertBefore(child, wrapper));
4047
}
4148
});
4249

0 commit comments

Comments
 (0)