Skip to content

Commit

Permalink
fix(labs): removing hasConstructed and setting privateIsConstructed t…
Browse files Browse the repository at this point in the history
…o handle setting tabIndex
  • Loading branch information
CarlosEGuerraSilva committed Feb 15, 2024
1 parent a6b8c09 commit ea518d0
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions labs/behaviors/focusable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -68,20 +67,18 @@ export function mixinFocusable<T extends MixinBase<LitElement>>(
this[updateTabIndex]();
}

[privateIsFocusable] = false;
[privateIsFocusable] = true;
[externalTabIndex]: number | null = null;
[isUpdatingTabIndex] = false;
[hasConstructed] = false;

// tslint:disable-next-line:no-any
constructor(...args: any[]) {
super(...args);
this[isFocusable] = true;
}

connectedCallback() {
override connectedCallback() {
super.connectedCallback();
this[hasConstructed] = true;
this[updateTabIndex]();
}

Expand Down Expand Up @@ -112,11 +109,6 @@ export function mixinFocusable<T extends MixinBase<LitElement>>(
}

[updateTabIndex]() {
if (!this[hasConstructed]) {
// Custom elements may not hydrate attributes during construction.
return;
}

const internalTabIndex = this[isFocusable] ? 0 : -1;
const computedTabIndex = this[externalTabIndex] ?? internalTabIndex;

Expand Down

0 comments on commit ea518d0

Please sign in to comment.