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
13 changes: 7 additions & 6 deletions radio/internal/single-selection-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,23 @@ export class SingleSelectionController implements ReactiveController {
constructor(private readonly host: SingleSelectionElement) {}

hostConnected() {
this.root = this.host.getRootNode() as ParentNode;
this.host.addEventListener('keydown', this.handleKeyDown);
this.host.addEventListener('focusin', this.handleFocusIn);
this.host.addEventListener('focusout', this.handleFocusOut);
if (this.host.checked) {
// Uncheck other siblings when attached if already checked. This mimics
// native <input type="radio"> behavior.
this.uncheckSiblings();
}

// 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.root = this.host.getRootNode() as ParentNode;
Comment thread
austinw-fineart marked this conversation as resolved.
if (this.host.checked) {
// Uncheck other siblings when attached if already checked. This mimics
// native <input type="radio"> behavior.
this.uncheckSiblings();
}

this.updateTabIndices();
});
}
Expand Down