From 7b1eeab613fffe833ea0f57a23d2cc11bef71ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Carvalho?= Date: Thu, 5 Sep 2024 10:43:14 +0100 Subject: [PATCH] fix: add null check in updated method of sp-number-field (#4709) --- packages/number-field/src/NumberField.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/number-field/src/NumberField.ts b/packages/number-field/src/NumberField.ts index 6119ed62e1..c5124adf61 100644 --- a/packages/number-field/src/NumberField.ts +++ b/packages/number-field/src/NumberField.ts @@ -796,6 +796,11 @@ export class NumberField extends TextfieldBase { } protected override updated(changes: PropertyValues): void { + if (!this.inputElement || !this.isConnected) { + // Prevent race conditions if inputElement is removed from DOM while a queued update is still running. + return; + } + if (changes.has('min') || changes.has('formatOptions')) { let inputMode = 'numeric'; const hasNegative = typeof this.min !== 'undefined' && this.min < 0;