Skip to content

Commit

Permalink
hide or show the select for regions instead of enabling/disabling in …
Browse files Browse the repository at this point in the history
…customer registration
  • Loading branch information
UB3RL33T committed Jun 14, 2019
1 parent 8e16abc commit 447aac0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/code/Magento/Checkout/view/frontend/web/js/region-updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ define([
regionInput = $(this.options.regionInputId),
postcode = $(this.options.postcodeId),
label = regionList.parent().siblings('label'),
requiredLabel = regionList.parents('div.field');
container = regionList.parents('div.field');

this._clearError();
this._checkRegionRequired(country);
Expand All @@ -181,15 +181,16 @@ define([

if (this.options.isRegionRequired) {
regionList.addClass('required-entry').removeAttr('disabled');
requiredLabel.addClass('required');
container.addClass('required').show();
} else {
regionList.removeClass('required-entry validate-select').removeAttr('data-validate');
requiredLabel.removeClass('required');
container.removeClass('required');

if (!this.options.optionalRegionAllowed) { //eslint-disable-line max-depth
regionList.attr('disabled', 'disabled');
regionList.hide();
container.hide();
} else {
regionList.removeAttr('disabled');
regionList.show();
}
}

Expand All @@ -201,12 +202,13 @@ define([

if (this.options.isRegionRequired) {
regionInput.addClass('required-entry').removeAttr('disabled');
requiredLabel.addClass('required');
container.addClass('required').show();
} else {
if (!this.options.optionalRegionAllowed) { //eslint-disable-line max-depth
regionInput.attr('disabled', 'disabled');
container.hide();
}
requiredLabel.removeClass('required');
container.removeClass('required');
regionInput.removeClass('required-entry');
}

Expand Down

0 comments on commit 447aac0

Please sign in to comment.