From 1d3a00c0224ad23cc924a77750d8517f00af6f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denilson=20S=C3=A1=20Maia?= Date: Fri, 13 Jun 2025 18:10:45 +0200 Subject: [PATCH] fix(form-core): don't remove event listeners if _focusableNode was not set This fix is similar to the previous commit. Under very specific circumstances on a very complicated application logic, a file input field (that extends from FocusMixin) gets created and immediately destroyed. This unfortunately causes an error, because the `disconnectedCallback()` gets called to remove the event listeners for a component that hasn't been fully set up. > Uncaught TypeError: this._focusableNode is null --- packages/ui/components/form-core/src/FocusMixin.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/ui/components/form-core/src/FocusMixin.js b/packages/ui/components/form-core/src/FocusMixin.js index ec7fdbe8d..457f0d927 100644 --- a/packages/ui/components/form-core/src/FocusMixin.js +++ b/packages/ui/components/form-core/src/FocusMixin.js @@ -198,6 +198,7 @@ const FocusMixinImplementation = superclass => * @private */ __teardownEventsForFocusMixin() { + if (!this._focusableNode) return; this._focusableNode?.removeEventListener( 'focus', /** @type {EventListenerOrEventListenerObject} */ (this.__redispatchFocus),