Skip to content

How can I check a Radio by default inside a RadioGroup? #511

@costinsin

Description

@costinsin

Hello!

Question: How can I check a Radio by default inside a RadioGroup?

I tried:

  1. Setting the checked attribute to one of the Radios. This breaks the RadioGroup, now having 2 radios checked.
    Image
    I figured the code in vscode-radio-group.ts can be changed to allow initial checked Radio:
  private _onSlotChange() {
    if (!this._firstContentLoaded) {
+     this._checkedRadio = this._radios.findIndex((r) => r.checked);
      const autoFocusedRadio = this._radios.findIndex((r) => r.autofocus);

      if (autoFocusedRadio > -1) {
        this._focusedRadio = autoFocusedRadio;
      }

      this._firstContentLoaded = true;
    }
  1. Setting the defaultChecked attribute to one of the Radios. This does nothing. It's like nothing was set in the first place. Does not break anything because it looks like it's ignored.

The result I want to end up to is having a Radio checked by default when I open my Webview. What is the recommended way to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions