Skip to content

Commit

Permalink
fix(labs): update tabIndex once the element is connected to the DOM
Browse files Browse the repository at this point in the history
Fix for #5398 , when hydrating tabIndex on radios and tabs, it causes a DOMException. The proposed solution suggests moving the hasConstructed property and calling the updateTabIndex method in the connectedCallback to be able to modify the tabIndex as soon as the element is connected to the DOM
  • Loading branch information
CarlosEGuerraSilva committed Feb 14, 2024
1 parent 6589b2e commit a6b8c09
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions labs/behaviors/focusable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ export function mixinFocusable<T extends MixinBase<LitElement>>(
constructor(...args: any[]) {
super(...args);
this[isFocusable] = true;
queueMicrotask(() => {
this[hasConstructed] = true;
this[updateTabIndex]();
});
}

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

override attributeChangedCallback(
Expand Down

0 comments on commit a6b8c09

Please sign in to comment.