Skip to content

Commit 98e7951

Browse files
8410: Custom Checkout Step and Shipping Step are Highlighted
1 parent a0b5460 commit 98e7951

File tree

4 files changed

+13
-28
lines changed

4 files changed

+13
-28
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ define([
6666
* @param {*} sortOrder
6767
*/
6868
registerStep: function (code, alias, title, isVisible, navigate, sortOrder) {
69-
var hash;
69+
var hash, active;
7070

7171
if ($.inArray(code, this.validCodes) !== -1) {
7272
throw new DOMException('Step code [' + code + '] already registered in step navigator');
@@ -87,6 +87,12 @@ define([
8787
navigate: navigate,
8888
sortOrder: sortOrder
8989
});
90+
active = this.getActiveItemIndex();
91+
steps.each(function (elem, index) {
92+
if (active !== index) {
93+
elem.isVisible(false);
94+
}
95+
});
9096
this.stepCodes.push(code);
9197
hash = window.location.hash.replace('#', '');
9298

@@ -111,10 +117,14 @@ define([
111117
getActiveItemIndex: function () {
112118
var activeIndex = 0;
113119

114-
steps.sort(this.sortItems).forEach(function (element, index) {
120+
steps.sort(this.sortItems).some(function (element, index) {
115121
if (element.isVisible()) {
116122
activeIndex = index;
123+
124+
return true;
117125
}
126+
127+
return false;
118128
});
119129

120130
return activeIndex;

app/code/Magento/Checkout/view/frontend/web/js/view/payment.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,8 @@ define([
4646

4747
/** @inheritdoc */
4848
initialize: function () {
49-
var self = this;
50-
5149
this._super();
5250
checkoutDataResolver.resolvePaymentMethod();
53-
54-
//If some step is active this step will become inactive.
55-
if (stepNavigator.steps()) {
56-
stepNavigator.steps().some(function (element) {
57-
if (element.isVisible()) {
58-
self.isVisible(false);
59-
60-
return true;
61-
}
62-
});
63-
}
64-
6551
stepNavigator.registerStep(
6652
'payment',
6753
null,

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,6 @@ define([
8282
this._super();
8383

8484
if (!quote.isVirtual()) {
85-
//If some step is active this step will become inactive.
86-
if (stepNavigator.steps()) {
87-
stepNavigator.steps().some(function (element) {
88-
if (element.isVisible()) {
89-
self.visible(false);
90-
91-
return true;
92-
}
93-
});
94-
}
95-
9685
stepNavigator.registerStep(
9786
'shipping',
9887
'',

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/view/shipping.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) {
4242
'Magento_Checkout/js/action/select-shipping-method': jasmine.createSpy(),
4343
'Magento_Checkout/js/model/shipping-rate-registry': jasmine.createSpy(),
4444
'Magento_Checkout/js/action/set-shipping-information': jasmine.createSpy(),
45-
'Magento_Checkout/js/model/step-navigator': jasmine.createSpyObj('navigator', ['registerStep', 'steps']),
45+
'Magento_Checkout/js/model/step-navigator': jasmine.createSpyObj('navigator', ['registerStep']),
4646
'Magento_Ui/js/modal/modal': jasmine.createSpy('modal').and.returnValue(modalStub),
4747
'Magento_Checkout/js/model/checkout-data-resolver': jasmine.createSpyObj(
4848
'dataResolver',

0 commit comments

Comments
 (0)