Skip to content

Commit

Permalink
Merge pull request #254 from SizeMeCom/fix-new-size-sel
Browse files Browse the repository at this point in the history
Fix for size sel CGKit empty selection
  • Loading branch information
nomasi authored Dec 1, 2023
2 parents cdf881d + 311d9ce commit 0a24fa5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/api/SizeSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ class SwatchesListButtonCGKit extends AbstractSelect {
constructor(element) {
super(element, { event: "click", useCapture: true });

this.allowEmptySizeSelection = false;
this.allowEmptySizeSelection = true;
this.getSize = (e) => {
const selected = e.target.closest("button");
return selected?.dataset.attributeValue ?? "";
Expand All @@ -515,7 +515,11 @@ class SwatchesListButtonCGKit extends AbstractSelect {
};

const options = element.querySelectorAll("button");
const mkSelectFn = (option) => () => option.click();
const mkSelectFn = (sizeItem) => () => {
if (!sizeItem.classList.contains("cgkit-swatch-selected")) {
sizeItem.click();
}
};
for (let i = 0; i < options.length; i++) {
const option = options.item(i);
const sizeValue = option.dataset.attributeValue;
Expand Down

0 comments on commit 0a24fa5

Please sign in to comment.