Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance how products work with localized content #238

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading