From fe02eaf84b057d03345aa1dc14c1d0cf988a16d5 Mon Sep 17 00:00:00 2001 From: Thijs Louisse Date: Fri, 18 Nov 2022 13:10:42 +0100 Subject: [PATCH] fix(lion-input-tel): polish/cleanup input-tel(-dropdown) --- .../src/LionInputTelDropdown.js | 21 ++++++++++++------- .../components/input-tel/src/LionInputTel.js | 9 -------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/packages/ui/components/input-tel-dropdown/src/LionInputTelDropdown.js b/packages/ui/components/input-tel-dropdown/src/LionInputTelDropdown.js index 261660a2e..877cdcc82 100644 --- a/packages/ui/components/input-tel-dropdown/src/LionInputTelDropdown.js +++ b/packages/ui/components/input-tel-dropdown/src/LionInputTelDropdown.js @@ -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); diff --git a/packages/ui/components/input-tel/src/LionInputTel.js b/packages/ui/components/input-tel/src/LionInputTel.js index 88d49d3d4..d2d376984 100644 --- a/packages/ui/components/input-tel/src/LionInputTel.js +++ b/packages/ui/components/input-tel/src/LionInputTel.js @@ -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();