Skip to content

Commit

Permalink
Address deprecated jQuery methods (#2466)
Browse files Browse the repository at this point in the history
Co-authored-by: sacr3dc0w <5056945+sacr3dc0w@users.noreply.github.com>
  • Loading branch information
sacr3dc0w and sacr3dc0w authored Jun 10, 2024
1 parent d37627d commit 6103fb6
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Remove remote_api_scripts to avoid double firing Meta Pixel analytics [#2467](https://github.com/bigcommerce/cornerstone/pull/2467)
- Prevent flow outside page container on account pages [#2462](https://github.com/bigcommerce/cornerstone/pull/2462)
- Account.js - Fixed jquery selector to be template literal [#2464](https://github.com/bigcommerce/cornerstone/pull/2464)
- Address deprecated jQuery methods [#2466](https://github.com/bigcommerce/cornerstone/pull/2466)

## 6.14.0 (05-15-2024)
- Account.php <a href> is inside of a list item [#2457](https://github.com/bigcommerce/cornerstone/pull/2457)
Expand Down
4 changes: 2 additions & 2 deletions assets/js/theme/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ export default class Account extends PageManager {
event.preventDefault();
setTimeout(() => {
const earliestError = $('span.form-inlineMessage:first').prev('input');
earliestError.focus();
earliestError.trigger('focus');
}, 900);
});
}
Expand Down Expand Up @@ -544,7 +544,7 @@ export default class Account extends PageManager {

setTimeout(() => {
const earliestError = $('span.form-inlineMessage:first').prev('input');
earliestError.focus();
earliestError.trigger('focus');
}, 900);
});
}
Expand Down
2 changes: 1 addition & 1 deletion assets/js/theme/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default class Auth extends PageManager {
event.preventDefault();
setTimeout(() => {
const earliestError = $('span.form-inlineMessage:first').prev('input');
earliestError.focus();
earliestError.trigger('focus');
}, 900);
}

Expand Down
17 changes: 10 additions & 7 deletions assets/js/theme/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,17 @@ export default class Cart extends PageManager {
});

// cart qty manually updates
$('.cart-item-qty-input', this.$cartContent).on('focus', function onQtyFocus() {
preVal = this.value;
}).change(event => {
const $target = $(event.currentTarget);
event.preventDefault();
$('.cart-item-qty-input', this.$cartContent).on({
focus: function onQtyFocus() {
preVal = this.value;
},
change: event => {
const $target = $(event.currentTarget);
event.preventDefault();

// update cart quantity
cartUpdateQtyTextChange($target, preVal);
// update cart quantity
cartUpdateQtyTextChange($target, preVal);
},
});

$('.cart-remove', this.$cartContent).on('click', event => {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/theme/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class CatalogPage extends PageManager {
const $sortBySelector = $('[data-sort-by="product"] #sort');

if (window.localStorage.getItem('sortByStatus')) {
$sortBySelector.focus();
$sortBySelector.trigger('focus');
window.localStorage.removeItem('sortByStatus');
}
}
Expand Down
4 changes: 2 additions & 2 deletions assets/js/theme/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class Category extends CatalogPage {
if (!$('[data-shop-by-price]').length) return;

if ($('.navList-action').hasClass('is-active')) {
$('a.navList-action.is-active').focus();
$('a.navList-action.is-active').trigger('focus');
}

$('a.navList-action').on('click', () => this.setLiveRegionAttributes($('span.price-filter-message'), 'status', 'assertive'));
Expand Down Expand Up @@ -61,7 +61,7 @@ export default class Category extends CatalogPage {
ariaNotifyNoProducts() {
const $noProductsMessage = $('[data-no-products-notification]');
if ($noProductsMessage.length) {
$noProductsMessage.focus();
$noProductsMessage.trigger('focus');
}
}

Expand Down
6 changes: 3 additions & 3 deletions assets/js/theme/common/aria/radioOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const setCheckedRadioItem = (itemCollection, itemIdx) => {
return;
}

$item.attr('aria-checked', true).prop('checked', true).focus();
$item.attr('aria-checked', true).prop('checked', true).trigger('focus');
$item.trigger('change');
});
};
Expand All @@ -35,14 +35,14 @@ const handleItemKeyDown = itemCollection => e => {
case ariaKeyCodes.LEFT:
case ariaKeyCodes.UP: {
const prevItemIdx = calculateTargetItemPosition(lastCollectionItemIdx, itemIdx - 1);
itemCollection.get(prevItemIdx).focus();
itemCollection.get(prevItemIdx).trigger('focus');
setCheckedRadioItem(itemCollection, itemIdx - 1);
break;
}
case ariaKeyCodes.RIGHT:
case ariaKeyCodes.DOWN: {
const nextItemIdx = calculateTargetItemPosition(lastCollectionItemIdx, itemIdx + 1);
itemCollection.get(nextItemIdx).focus();
itemCollection.get(nextItemIdx).trigger('focus');
setCheckedRadioItem(itemCollection, itemIdx + 1);
break;
}
Expand Down
8 changes: 4 additions & 4 deletions assets/js/theme/common/carousel/utils/refreshFocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ export default ($prevArrow, $nextArrow, $dots, $slider, activeSlideIdx, slidesQu
if (isInfinite || !$prevArrow || !$nextArrow) return;

if (activeSlideIdx === 0 && $prevArrow.is(':focus')) {
$nextArrow.focus();
$nextArrow.trigger('focus');
} else if (activeSlideIdx === slidesQuantity - 1 && $nextArrow.is(':focus')) {
if ($dots) {
$dots.children().first().find('[data-carousel-dot]').focus();
$dots.children().first().find('[data-carousel-dot]').trigger('focus');
return;
}

const $firstActiveSlide = $slider.find('.slick-active').first();

if ($firstActiveSlide.is(FOCUSABLE_ELEMENTS_SELECTOR)) {
$firstActiveSlide.focus();
} else $firstActiveSlide.find(FOCUSABLE_ELEMENTS_SELECTOR).first().focus();
$firstActiveSlide.trigger('focus');
} else $firstActiveSlide.find(FOCUSABLE_ELEMENTS_SELECTOR).first().trigger('focus');
}
};
2 changes: 1 addition & 1 deletion assets/js/theme/gift-certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export default class GiftCertificate extends PageManager {
});
};

$('#gift-certificate-preview').click(event => {
$('#gift-certificate-preview').on('click', event => {
event.preventDefault();

purchaseValidator.performCheck();
Expand Down
2 changes: 1 addition & 1 deletion assets/js/theme/global/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class Modal {

if (this.focusTrap) this.focusTrap.deactivate();

if (this.$preModalFocusedEl) this.$preModalFocusedEl.focus();
if (this.$preModalFocusedEl) this.$preModalFocusedEl.trigger('focus');

this.$preModalFocusedEl = null;
}
Expand Down
4 changes: 2 additions & 2 deletions assets/js/theme/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default class Search extends CatalogPage {
default: break;
}

$($tabsCollection.get(nextTabIdx)).focus().trigger('click');
$($tabsCollection.get(nextTabIdx)).trigger('focus').trigger('click');
}

onReady() {
Expand Down Expand Up @@ -212,7 +212,7 @@ export default class Search extends CatalogPage {
>${this.context.searchResultsCount}</p>`)
.prependTo('body');

setTimeout(() => $searchResultsMessage.focus(), 100);
setTimeout(() => $searchResultsMessage.trigger('focus'), 100);
}

loadTreeNodes(node, cb) {
Expand Down

0 comments on commit 6103fb6

Please sign in to comment.