Skip to content

Commit

Permalink
Merge pull request #474 from BitBagCommerce/hotfix/javascript-build-f…
Browse files Browse the repository at this point in the history
…ixes

OP-152: Fix issues with broken build on webpack and node 14
  • Loading branch information
senghe committed Apr 27, 2023
2 parents a9e6699 + 2553153 commit 431862e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/Resources/assets/admin/js/bitbag/bitbag-media-autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ export class HandleAutoComplete {
const data = await res.json();

this._addToSelectMenu(data, mediaContainer);
let children = mediaContainer.querySelector(this.selectMenu)?.children
let children = [];
let selectedContainer = mediaContainer.querySelector(this.selectMenu);
if (selectedContainer !== null) {
children = selectedContainer.children;
}
for (let child of children) {
child.click();
}
Expand Down Expand Up @@ -155,9 +159,11 @@ export class HandleAutoComplete {
triggerCustomEvent(mediaContainer, 'cms.media.display.update.start');
const selectMenu = mediaContainer.querySelector(this.selectMenu);
selectMenu.innerHTML = '';
arr?.forEach((item) => {
selectMenu.insertAdjacentHTML('beforeend', this._itemTemplate(item.path, item.code.trim()));
});
if (arr !== null) {
arr.forEach((item) => {
selectMenu.insertAdjacentHTML('beforeend', this._itemTemplate(item.path, item.code.trim()));
});
}
triggerCustomEvent(mediaContainer, 'cms.media.display.update.end');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/assets/admin/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if (document.querySelector('[data-bb-target="cms-import"]')) {
new HandleCsvUpload().init();
}

if (document.querySelectorAll('[data-bb-target="cms-slug-update"]')?.length > 0) {
if (document.querySelectorAll('[data-bb-target="cms-slug-update"]').length > 0) {
new HandleSlugUpdate().init();
}

Expand Down

0 comments on commit 431862e

Please sign in to comment.