From 1e5483e9416e4ac45e183f8bd106ecae2b9735b5 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Wed, 2 Mar 2022 15:59:06 +0100 Subject: [PATCH] Fix input issue with phone numbers --- UI/Input/TextField.ts | 6 +++--- UI/Input/ValidatedTextField.ts | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/UI/Input/TextField.ts b/UI/Input/TextField.ts index 905188a15..051ff1652 100644 --- a/UI/Input/TextField.ts +++ b/UI/Input/TextField.ts @@ -7,7 +7,7 @@ export class TextField extends InputElement { public readonly enterPressed = new UIEventSource(undefined); private readonly value: UIEventSource; private _element: HTMLElement; - private readonly _isValid: (s: string, country?: () => string) => boolean; + private readonly _isValid: (s: string) => boolean; private _rawValue: UIEventSource constructor(options?: { @@ -18,7 +18,7 @@ export class TextField extends InputElement { label?: BaseUIElement, textAreaRows?: number, inputStyle?: string, - isValid?: ((s: string, country?: () => string) => boolean) + isValid?: (s: string) => boolean }) { super(); const self = this; @@ -140,7 +140,7 @@ export class TextField extends InputElement { if (t === undefined || t === null) { return false } - return this._isValid(t, undefined); + return this._isValid(t); } protected InnerConstructElement(): HTMLElement { diff --git a/UI/Input/ValidatedTextField.ts b/UI/Input/ValidatedTextField.ts index 9359289d4..9164a2851 100644 --- a/UI/Input/ValidatedTextField.ts +++ b/UI/Input/ValidatedTextField.ts @@ -25,7 +25,6 @@ import Title from "../Base/Title"; import InputElementMap from "./InputElementMap"; import Translations from "../i18n/Translations"; import {Translation} from "../i18n/Translation"; -import {NOTFOUND} from "dns"; export class TextFieldDef { @@ -97,7 +96,7 @@ export class TextFieldDef { return self.isValid(stripped, options.country) } } else { - options["isValid"] = self.isValid; + options["isValid"] = str => self.isValid(str, options.country); } @@ -752,7 +751,7 @@ class PhoneTextField extends TextFieldDef { if (str.startsWith("tel:")) { str = str.substring("tel:".length) } - return parsePhoneNumberFromString(str, (country())?.toUpperCase() as any).formatInternational(); + return parsePhoneNumberFromString(str, (country())?.toUpperCase() as any)?.formatInternational(); } }