-
Notifications
You must be signed in to change notification settings - Fork 166
LG-6026: Telephone input country listing is not translated #6336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
19621be
cc47ff5
9ed09e4
91616bf
ed1a31c
899d430
03277a1
34eaa61
7606c8e
d0bcadb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,15 +42,20 @@ export class PhoneInput extends HTMLElement { | |||||||||||
| /** @type {string[]} */ | ||||||||||||
| deliveryMethods = []; | ||||||||||||
|
|
||||||||||||
| /** @type {Object.<string,*>} */ | ||||||||||||
| countryCodePairs = {}; | ||||||||||||
|
|
||||||||||||
| connectedCallback() { | ||||||||||||
| /** @type {HTMLInputElement?} */ | ||||||||||||
| this.textInput = this.querySelector('.phone-input__number'); | ||||||||||||
| /** @type {HTMLSelectElement?} */ | ||||||||||||
| this.codeInput = this.querySelector('.phone-input__international-code'); | ||||||||||||
| this.codeWrapper = this.querySelector('.phone-input__international-code-wrapper'); | ||||||||||||
| this.exampleText = this.querySelector('.phone-input__example'); | ||||||||||||
|
|
||||||||||||
| try { | ||||||||||||
| this.deliveryMethods = JSON.parse(this.dataset.deliveryMethods || ''); | ||||||||||||
| this.countryCodePairs = JSON.parse(this.dataset.translatedCountryCodeNames || ''); | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not that I would expect it to fail, but one downside of grouping these assignments in the same To me, it seems like either we should trust that they'd always parse correctly and avoid the
Suggested change
|
||||||||||||
| } catch {} | ||||||||||||
|
|
||||||||||||
| if (!this.textInput || !this.codeInput) { | ||||||||||||
|
|
@@ -118,11 +123,12 @@ export class PhoneInput extends HTMLElement { | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| initializeIntlTelInput() { | ||||||||||||
| const { supportedCountryCodes } = this; | ||||||||||||
| const { supportedCountryCodes, countryCodePairs } = this; | ||||||||||||
| const allowDropdown = supportedCountryCodes && supportedCountryCodes.length > 1; | ||||||||||||
|
|
||||||||||||
| const iti = intlTelInput(this.textInput, { | ||||||||||||
| preferredCountries: ['US', 'CA'], | ||||||||||||
| localizedCountries: countryCodePairs, | ||||||||||||
| onlyCountries: supportedCountryCodes, | ||||||||||||
| autoPlaceholder: 'off', | ||||||||||||
| allowDropdown, | ||||||||||||
|
|
||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks to me like it works in practice, though my understanding is that it's recommended to avoid the uppercase "Object" type (along with a few others). Also, would we be safe to assume that the expected value should be a string?
Maybe one of these:
The latter comes from the DefinitelyTyped types for the library, in case we want to align to that, and optionally add it as a devDependency to our project.