Skip to content

Commit

Permalink
fix(storefront): BCTHEME-1089 Incorrect handling of unsuccessful item…
Browse files Browse the repository at this point in the history
… removing from cart on the Cart page. (#2211)
  • Loading branch information
bc-yevhenii-buliuk authored May 16, 2022
1 parent abcef2e commit 8a2f895
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Draft
- Incorrect handling of unsuccessful item removing from cart on the Cart page. [#2211](https://github.com/bigcommerce/cornerstone/issues/2211)

## 6.4.0 (05-11-2022)
- Remove adminBar translations from da/no lang files [#2209](https://github.com/bigcommerce/cornerstone/issues/2209)
Expand Down
1 change: 1 addition & 0 deletions assets/js/theme/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default class Cart extends PageManager {
if (response.data.status === 'succeed') {
this.refreshContent(true);
} else {
this.$overlay.hide();
showAlertModal(response.data.errors.join('\n'));
}
});
Expand Down
13 changes: 9 additions & 4 deletions assets/js/theme/global/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ export function alertModal() {
*/
export function showAlertModal(message, options = {}) {
const modal = alertModal();
const cancelBtn = modal.$modal.find('.cancel');
const $cancelBtn = modal.$modal.find('.cancel');
const $confirmBtn = modal.$modal.find('.confirm');
const {
icon = 'error',
$preModalFocusedEl = null,
Expand All @@ -322,12 +323,16 @@ export function showAlertModal(message, options = {}) {
modal.updateContent(`<span>${message}</span>`);

if (onConfirm) {
modal.$modal.find('.confirm').on('click', onConfirm);
$confirmBtn.on('click', onConfirm);

modal.$modal.one(ModalEvents.closed, () => {
$confirmBtn.off('click', onConfirm);
});
}

if (showCancelButton) {
cancelBtn.show();
$cancelBtn.show();
} else {
cancelBtn.hide();
$cancelBtn.hide();
}
}

0 comments on commit 8a2f895

Please sign in to comment.