Skip to content

Commit

Permalink
BCTHEME154: fix issue with add product to cart on ie11 (#1762)
Browse files Browse the repository at this point in the history
Co-authored-by: BC-tymurbiedukhin <66319629+BC-tymurbiedukhin@users.noreply.github.com>
  • Loading branch information
bc-alexsaiannyi and BC-tymurbiedukhin authored Aug 26, 2020
1 parent c0e13be commit e782568
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Draft
- Fixed failing to add product to cart on IE11 [#1762](https://github.com/bigcommerce/cornerstone/pull/1762)
- Fixed overlaping at footer columns when long texts (without spaces) are entered [#1753](https://jira.bigcommerce.com/browse/BCTHEME-43)

## 4.9.0 (07-28-2020)
Expand Down
2 changes: 2 additions & 0 deletions assets/js/polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'regenerator-runtime/runtime';
import 'whatwg-fetch';
import objectFitImages from 'object-fit-images';

require('formdata-polyfill');

document.addEventListener('DOMContentLoaded', () => {
objectFitImages();
});
10 changes: 8 additions & 2 deletions assets/js/theme/common/product-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import modalFactory, { showAlertModal } from '../global/modal';
import _ from 'lodash';
import Wishlist from '../wishlist';
import { normalizeFormData } from './utils/api';
import { isBrowserIE, convertIntoArray } from './utils/ie-helpers';

export default class ProductDetails {
constructor($scope, context, productAttributesData = {}) {
Expand Down Expand Up @@ -108,15 +109,20 @@ export default class ProductDetails {
if (type === 'set-rectangle' || type === 'set-radio' || type === 'swatch' || type === 'input-checkbox' || type === 'product-list') {
const checked = value.querySelector(':checked');
if (checked) {
const getSelectedOptionLabel = () => {
const productVariantslist = convertIntoArray(value.children);
const matchLabelForCheckedInput = inpt => inpt.dataset.productAttributeValue === checked.value;
return productVariantslist.filter(matchLabelForCheckedInput)[0];
};
if (type === 'set-rectangle' || type === 'set-radio' || type === 'product-list') {
const label = checked.labels[0].innerText;
const label = isBrowserIE ? getSelectedOptionLabel().innerText.trim() : checked.labels[0].innerText;
if (label) {
options.push(`${optionTitle}:${label}`);
}
}

if (type === 'swatch') {
const label = checked.labels[0].children[0];
const label = isBrowserIE ? getSelectedOptionLabel().children[0] : checked.labels[0].children[0];
if (label) {
options.push(`${optionTitle}:${label.title}`);
}
Expand Down
3 changes: 3 additions & 0 deletions assets/js/theme/common/utils/ie-helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const isBrowserIE = navigator.userAgent.includes('Trident');

export const convertIntoArray = collection => Array.prototype.slice.call(collection);
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"creditcards": "^3.0.1",
"easyzoom": "^2.5.3",
"focus-within-polyfill": "^5.0.9",
"formdata-polyfill": "^3.0.20",
"foundation-sites": "^5.5.3",
"jquery": "^3.5.1",
"jquery.tabbable": "^1.0.1",
Expand Down

0 comments on commit e782568

Please sign in to comment.