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

Fix an error #2903

Merged
merged 3 commits into from
Jul 24, 2023
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
5 changes: 3 additions & 2 deletions assets/quick-order-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class QuickOrderList extends HTMLElement {
renderSections(parsedState) {
this.getSectionsToRender().forEach((section => {
const sectionElement = document.getElementById(section.id);
if (sectionElement.parentElement.classList.contains('drawer')) {
if (sectionElement && sectionElement.parentElement && sectionElement.parentElement.classList.contains('drawer')) {
parsedState.items.length > 0 ? sectionElement.parentElement.classList.remove('is-empty') : sectionElement.parentElement.classList.add('is-empty');

setTimeout(() => {
Expand Down Expand Up @@ -284,9 +284,10 @@ class QuickOrderList extends HTMLElement {
} else {
this.updateMessage(-parseInt(quantityElement.dataset.cartQuantity))
}
}).catch(() => {
}).catch((error) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the console log

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kai suggested to keep it, so next time we will know right away what’s causing the error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont really add this in other places 🤔 Shouldnt we just add it if we are debugging?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can keep the logging. We actually log errors to the console in a few places in the theme (search for console.error).

In normal circumstances, we should never see any errors logged, but when making changes it's probably better to see an error in the console and catch it early rather than missing a suppressed error.

Copy link
Contributor

@sofiamatulis sofiamatulis Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh I was searching for console.log . Thank you!

this.querySelectorAll('.loading-overlay').forEach((overlay) => overlay.classList.add('hidden'));
this.resetQuantityInput(id);
console.error(error);
this.setErrorMessage(window.cartStrings.error);
})
.finally(() => {
Expand Down