Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions radio/internal/single-selection-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,29 @@ export class SingleSelectionController implements ReactiveController {
this.uncheckSiblings();
}

// Update for the newly added host.
this.updateTabIndices();
// Update siblings after a microtask to allow other synchronous connected
// callbacks to settle before triggering additional Lit updates. This avoids
// stack overflow issues when too many elements are being rendered and
// connected at the same time.
queueMicrotask(() => {
// Update for the newly added host.
this.updateTabIndices();
});
}

hostDisconnected() {
this.host.removeEventListener('keydown', this.handleKeyDown);
this.host.removeEventListener('focusin', this.handleFocusIn);
this.host.removeEventListener('focusout', this.handleFocusOut);
// Update for siblings that are still connected.
this.updateTabIndices();
this.root = null;
// Update siblings after a microtask to allow other synchronous disconnected
// callbacks to settle before triggering additional Lit updates. This avoids
// stack overflow issues when too many elements are being rendered and
// connected at the same time.
queueMicrotask(() => {
// Update for siblings that are still connected.
this.updateTabIndices();
this.root = null;
});
}

/**
Expand Down
Loading