fix(lion-input-tel): polish/cleanup input-tel(-dropdown)

This commit is contained in:
Thijs Louisse 2022-11-18 13:10:42 +01:00 committed by Thijs Louisse
parent 9d912f6618
commit fe02eaf84b
2 changed files with 14 additions and 16 deletions

View file

@ -177,9 +177,7 @@ export class LionInputTelDropdown extends LionInputTel {
return {
template: templates.dropdown(this._templateDataDropdown),
afterRender: () => {
this.__syncRegionWithDropdown();
},
afterRender: this.__syncRegionWithDropdown,
};
},
};
@ -204,8 +202,6 @@ export class LionInputTelDropdown extends LionInputTel {
_onPhoneNumberUtilReady() {
super._onPhoneNumberUtilReady();
this.__createRegionMeta();
// render dropdown (trigger render of prefix slot via SlotMixin)
this.requestUpdate();
}
/**
@ -233,19 +229,27 @@ export class LionInputTelDropdown extends LionInputTel {
/**
* Contains everything needed for rendering region options:
* region code, country code, display name according to locale, display name
* @private
* @type {RegionMeta[]}
*/
this.__regionMetaList = [];
/**
* A filtered `this.__regionMetaList`, containing all regions provided in `preferredRegions`
* @private
* @type {RegionMeta[]}
*/
this.__regionMetaListPreferred = [];
/** @type {EventListener} */
/**
* @protected
* @type {EventListener}
*/
this._onDropdownValueChange = this._onDropdownValueChange.bind(this);
/** @type {EventListener} */
/**
* @private
* @type {EventListener}
*/
this.__syncRegionWithDropdown = this.__syncRegionWithDropdown.bind(this);
}
@ -284,6 +288,9 @@ export class LionInputTelDropdown extends LionInputTel {
}
}
/**
* @protected
*/
_initModelValueBasedOnDropdown() {
if (!this._initialModelValue && !this.dirty && this._phoneUtil) {
const countryCode = this._phoneUtil.getCountryCodeForRegionCode(this.activeRegion);

View file

@ -28,7 +28,6 @@ export class LionInputTel extends LocalizeMixin(LionInput) {
formatCountryCodeStyle: { type: String, attribute: 'format-country-code-style' },
activeRegion: { type: String },
_phoneUtil: { type: Object, state: true },
_needsLightDomRender: { type: Number, state: true },
};
static localizeNamespaces = [
@ -171,14 +170,6 @@ export class LionInputTel extends LocalizeMixin(LionInput) {
? /** @type {AwesomePhoneNumber} */ (PhoneUtilManager.PhoneUtil)
: null;
/**
* Helper that triggers a light dom render aligned with update loop.
* TODO: combine with render fn of SlotMixin
* @protected
* @type {number}
*/
this._needsLightDomRender = 0;
if (!PhoneUtilManager.isLoaded) {
PhoneUtilManager.loadComplete.then(() => {
this._onPhoneNumberUtilReady();