Skip to content

Commit

Permalink
Merge pull request #238 from hlxsites/ian/products-localization
Browse files Browse the repository at this point in the history
Enhance how products work with localized content
  • Loading branch information
iansk authored Mar 28, 2024
2 parents 81b0af5 + aae9e91 commit bf99028
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions blocks/sidenav/sidenav.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ async function navigateArticleSPA(ev) {
handleSPANavigation(state);
}

function disableProductButton(button) {
const buttonDownArrow = button.querySelector('.icon-container');

button.setAttribute('disabled', true);
buttonDownArrow.setAttribute('hidden', true);
}

/**
* Add product dropdown
* @param {Element} wrapper
Expand Down Expand Up @@ -229,7 +236,7 @@ const initProductDropdown = async (wrapper) => {
}
});

const json = await store.fetchJSON(`${window.location.origin}${PATH_PREFIX}/products`);
const json = await store.fetchJSON(`${window.location.origin}${PATH_PREFIX}/${lang}/products`);

if (!json) return;

Expand Down Expand Up @@ -261,7 +268,11 @@ const initProductDropdown = async (wrapper) => {
})
.filter((item) => !!item);

productsDropdownMenu.append(...newProducts);
if (newProducts.length) {
productsDropdownMenu.append(...newProducts);
} else {
disableProductButton(productButton);
}
};

/**
Expand Down

0 comments on commit bf99028

Please sign in to comment.