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(storefront): STRF-5282 Unable to add products to cart with 2 or more non-required File Upload options using Safari #1337

Merged
merged 1 commit into from
Sep 12, 2018

Conversation

bc-NikitaPuzanenko
Copy link
Contributor

What?

Safari only does one iteration in the currentfor of loop. This change will create a new FormData object and append valid entries using a standard for loop instead.

Screenshots (if appropriate)

Before:
before

After:
after

@bigbot
Copy link

bigbot commented Aug 27, 2018

Autotagging @bigcommerce/storefront-team @davidchin

formData.delete(key);
const filteredFormData = new FormData();
for (let i = 0; i < form.elements.length; i++) {
if (form.elements[i].type !== 'file' && form.elements[i].value && form.elements[i].name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be cleaned up a bit:

let element = form.elements[i];
if (element.type === 'file' && element.size > 0) {
    filteredFormData.append(element.name, element.files[0], element.files[0].name);
} else if (element.name && element.value) {
    filteredFormData.append(element.name, element.value);
}

Copy link
Contributor

@Ubersmake Ubersmake left a comment

Choose a reason for hiding this comment

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

Tried applying these changes to Cornerstone latest. It...actually doesn't work. Blocking the PR until we can figure out what happened.

…ore non-required File Upload options using Safari
Copy link
Contributor

@Ubersmake Ubersmake left a comment

Choose a reason for hiding this comment

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

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants