From 570cbc67cecc4e8fe279416f4b3e756e64b9ad10 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Thu, 24 Jun 2021 02:33:26 +0200 Subject: [PATCH] Link value of OHInput, make combinedInputElement more resilient; formatting --- UI/Input/CombinedInputElement.ts | 6 +++--- UI/Input/ValidatedTextField.ts | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/UI/Input/CombinedInputElement.ts b/UI/Input/CombinedInputElement.ts index 38d3fc7bcd..b1fa39a8e4 100644 --- a/UI/Input/CombinedInputElement.ts +++ b/UI/Input/CombinedInputElement.ts @@ -24,13 +24,13 @@ export default class CombinedInputElement extends InputElement { }, [b.IsSelected]) this._combined = new Combine([this._a, this._b]); this._value = this._a.GetValue().map( - t => combine(t, this._b.GetValue().data), + t => combine(t, this._b?.GetValue()?.data), [this._b.GetValue()], ) .addCallback(x => { const [t, j] = split(x) - this._a.GetValue().setData(t) - this._b.GetValue().setData(j) + this._a.GetValue()?.setData(t) + this._b.GetValue()?.setData(j) }) } diff --git a/UI/Input/ValidatedTextField.ts b/UI/Input/ValidatedTextField.ts index 475f6cf423..f6292c1bce 100644 --- a/UI/Input/ValidatedTextField.ts +++ b/UI/Input/ValidatedTextField.ts @@ -264,11 +264,12 @@ export default class ValidatedTextField { } if (tp.inputHelper) { - input = new CombinedInputElement(input, tp.inputHelper(input.GetValue(), { - location: options.location, - mapBackgroundLayer: options.mapBackgroundLayer + const helper = tp.inputHelper(input.GetValue(), { + location: options.location, + mapBackgroundLayer: options.mapBackgroundLayer - }), + }) + input = new CombinedInputElement(input, helper, (a, _) => a, // We can ignore b, as they are linked earlier a => [a, a] );