Skip to content

Commit 19e1c5a

Browse files
committed
ACP2E-1609: Region Field is not getting blank after selecting any region for a country
1 parent 3270c97 commit 19e1c5a

File tree

1 file changed

+9
-3
lines changed
  • app/code/Magento/Customer/view/adminhtml/web/js/form/element

1 file changed

+9
-3
lines changed

app/code/Magento/Customer/view/adminhtml/web/js/form/element/region.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ define([
2121
setDifferedFromDefault: function (value) {
2222
this._super();
2323

24-
let label = parseFloat(value) ? this.indexedOptions[value].label : '';
25-
26-
this.source.set(this.regionScope,label);
24+
const indexedOptionsArray = Object.values(this.indexedOptions),
25+
countryId = this.source.data.country_id,
26+
hasRegionList = indexedOptionsArray.some(option => option.country_id === countryId);
2727

28+
this.source.set(
29+
this.regionScope,
30+
hasRegionList
31+
? parseFloat(value) ? this.indexedOptions?.[value]?.label || '' : ''
32+
: this.source.data?.region || ''
33+
);
2834
}
2935
});
3036
});

0 commit comments

Comments
 (0)