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] QOL Cart race conditions #3395

Merged
merged 36 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5bb438c
Cart racing prototype
sofiamatulis Apr 4, 2024
c1037b7
Add promise
sofiamatulis Apr 4, 2024
1a8c8ce
new approach
sofiamatulis Apr 4, 2024
6c6c785
Refactor
sofiamatulis Apr 5, 2024
64a2788
Fix multiple items
sofiamatulis Apr 5, 2024
7f2aee0
Merge branch 'main' into cart-racing
sofiamatulis Apr 5, 2024
d6170be
Merge branch 'main' into cart-racing
sofiamatulis Apr 25, 2024
3b0bc2b
Fix closing tag
sofiamatulis Apr 25, 2024
29ae036
Clean up
sofiamatulis Apr 25, 2024
b900e52
Remove unused var
sofiamatulis Apr 25, 2024
e5f185b
Remove name
sofiamatulis Apr 25, 2024
b76ead6
Clean up ids
sofiamatulis Apr 25, 2024
4e6fb73
Clean up func
sofiamatulis Apr 25, 2024
d208999
Clean up function
sofiamatulis Apr 25, 2024
2f164c5
Check if remove all exists
sofiamatulis Apr 25, 2024
9fc8728
Check if remove all exists
sofiamatulis Apr 25, 2024
e64ce07
Ensure it only updates when the user is done
sofiamatulis Apr 25, 2024
a835730
Remove unused promise
sofiamatulis Apr 26, 2024
0954f4f
Update debouncer
sofiamatulis Apr 29, 2024
1956e70
Fix typo
sofiamatulis Apr 30, 2024
6471174
Create extendable comp
sofiamatulis Apr 30, 2024
7e9500b
import js file
sofiamatulis May 1, 2024
b90f7a5
Feedback
sofiamatulis May 1, 2024
8c119b1
feedback
sofiamatulis May 2, 2024
9b482c8
Update settings json
sofiamatulis May 2, 2024
16e1319
Revert
sofiamatulis May 2, 2024
2623ff8
Fix trash behavior
sofiamatulis May 2, 2024
1177dc1
Revert settings
sofiamatulis May 3, 2024
1d99424
naming
sofiamatulis May 3, 2024
88fe218
Ensure remove buton updates
sofiamatulis May 3, 2024
b51ef46
Fix spacing
sofiamatulis May 3, 2024
4f353f7
Cleanup
sofiamatulis May 3, 2024
e8e7f86
Fix duplication
sofiamatulis May 3, 2024
d7b966c
Fix trash icon behavior;
sofiamatulis May 3, 2024
0683db8
Fix logic
sofiamatulis May 4, 2024
e349ace
Fix loader
sofiamatulis May 6, 2024
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
Prev Previous commit
Next Next commit
Ensure remove buton updates
  • Loading branch information
sofiamatulis committed May 3, 2024
commit 88fe2181e13df11ef71a469e1f3054264af9c2cd
2 changes: 1 addition & 1 deletion assets/quick-order-list.css
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ quick-order-list .quantity__button {
color: rgb(var(--color-foreground));
}

quick-order-list-remove-button {
.variant-item__remove{
display: flex;
margin: 0 0 0 1.2rem;
align-self: center;
Expand Down
70 changes: 37 additions & 33 deletions assets/quick-order-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,42 +262,46 @@ if (!customElements.get('quick-order-list')) {

renderSections(parsedState, ids) {
const intersection = this.queue.filter(element => ids.includes(element.id));
if (intersection.length === 0) {
this.getSectionsToRender().forEach((section) => {
const sectionElement = document.getElementById(section.id);
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(() => {
document.querySelector('#CartDrawer-Overlay').addEventListener('click', this.cart.close.bind(this.cart));
});
}
const elementToReplace =
sectionElement && sectionElement.querySelector(section.selector)
? sectionElement.querySelector(section.selector)
: sectionElement;
if (elementToReplace) {
if (section.selector === `#${this.quickOrderListId} .js-contents` && ids !== undefined) {
ids.forEach((i) => {
this.getSectionsToRender().forEach((section) => {
const sectionElement = document.getElementById(section.id);
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(() => {
document.querySelector('#CartDrawer-Overlay').addEventListener('click', this.cart.close.bind(this.cart));
});
}
const elementToReplace =
sectionElement && sectionElement.querySelector(section.selector)
? sectionElement.querySelector(section.selector)
: sectionElement;
if (elementToReplace) {
if (section.selector === `#${this.quickOrderListId} .js-contents` && ids !== undefined) {
ids.forEach((i) => {
if (intersection.length === 0) {
elementToReplace.querySelector(`#Variant-${i}`).innerHTML =
this.getSectionInnerHTML(parsedState.sections[section.section], `#Variant-${i}`);
});
} else {
elementToReplace.innerHTML = this.getSectionInnerHTML(
parsedState.sections[section.section],
section.selector
);
}
} else {
elementToReplace.querySelector(`#Variant-${i} .variant-item__remove`).innerHTML =
this.getSectionInnerHTML(parsedState.sections[section.section], `#Variant-${i} .variant-item__remove`);
}

});
} else {
elementToReplace.innerHTML = this.getSectionInnerHTML(
parsedState.sections[section.section],
section.selector
);
}
});
this.defineInputsAndQuickOrderTable();
this.addMultipleDebounce();
}
}
});
this.defineInputsAndQuickOrderTable();
this.addMultipleDebounce();
}

getTableHead() {
Expand Down
28 changes: 15 additions & 13 deletions snippets/quick-order-list-row.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -284,20 +284,22 @@
{% render 'quantity-input', variant: variant, min: 0 %}
{%- endif -%}
</div>
{%- if cart_qty > 0 -%}
<quick-order-list-remove-button
id="Remove-{{ variant.id }}"
data-index="{{ variant.id }}"
>
<a
href="{{ item.url_to_remove }}"
class="button button--tertiary"
aria-label="{{ 'sections.cart.remove_title' | t: title: item.title }}"
<div class="variant-item__remove">
{%- if cart_qty > 0 -%}
<quick-order-list-remove-button
id="Remove-{{ variant.id }}"
data-index="{{ variant.id }}"
>
{% render 'icon-remove' %}
</a>
</quick-order-list-remove-button>
{%- endif -%}
<a
href="{{ item.url_to_remove }}"
class="button button--tertiary"
aria-label="{{ 'sections.cart.remove_title' | t: title: item.title }}"
>
{% render 'icon-remove' %}
</a>
</quick-order-list-remove-button>
{%- endif -%}
</div>
</div>
{%- if has_popover -%}
<button
Expand Down
Loading