From ea518d0353facd94037843aca7e623b91a16363c Mon Sep 17 00:00:00 2001 From: Carlos Guerra Date: Thu, 15 Feb 2024 01:38:19 -0600 Subject: [PATCH] fix(labs): removing hasConstructed and setting privateIsConstructed to handle setting tabIndex --- labs/behaviors/focusable.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/labs/behaviors/focusable.ts b/labs/behaviors/focusable.ts index 98466d36b2..48ff2049c1 100644 --- a/labs/behaviors/focusable.ts +++ b/labs/behaviors/focusable.ts @@ -30,7 +30,6 @@ const privateIsFocusable = Symbol('privateIsFocusable'); const externalTabIndex = Symbol('externalTabIndex'); const isUpdatingTabIndex = Symbol('isUpdatingTabIndex'); const updateTabIndex = Symbol('updateTabIndex'); -const hasConstructed = Symbol('hasConstructed'); /** * Mixes in focusable functionality for a class. @@ -68,10 +67,9 @@ export function mixinFocusable>( this[updateTabIndex](); } - [privateIsFocusable] = false; + [privateIsFocusable] = true; [externalTabIndex]: number | null = null; [isUpdatingTabIndex] = false; - [hasConstructed] = false; // tslint:disable-next-line:no-any constructor(...args: any[]) { @@ -79,9 +77,8 @@ export function mixinFocusable>( this[isFocusable] = true; } - connectedCallback() { + override connectedCallback() { super.connectedCallback(); - this[hasConstructed] = true; this[updateTabIndex](); } @@ -112,11 +109,6 @@ export function mixinFocusable>( } [updateTabIndex]() { - if (!this[hasConstructed]) { - // Custom elements may not hydrate attributes during construction. - return; - } - const internalTabIndex = this[isFocusable] ? 0 : -1; const computedTabIndex = this[externalTabIndex] ?? internalTabIndex;