Skip to content

Allow activation of a checked radio button to clear it#12480

Open
hjanuschka wants to merge 1 commit into
whatwg:mainfrom
hjanuschka:clearable-radio-activation
Open

Allow activation of a checked radio button to clear it#12480
hjanuschka wants to merge 1 commit into
whatwg:mainfrom
hjanuschka:clearable-radio-activation

Conversation

@hjanuschka

@hjanuschka hjanuschka commented May 24, 2026

Copy link
Copy Markdown

This changes radio button activation so a user can return an optional radio group to its no-selection state by activating the checked radio button again.

Use case: optional questions in long forms.

Chromium issue 40761596 describes a form with an optional gender question. The form text says not to pick an option if none applies, but if the user accidentally selects one radio button, native radio behavior gives them no built-in way to return to the original no-selection state. They must rely on the page providing a separate clear/reset control, script, or discard the form.

Radio groups already support a no-selection state:

  • a group can initially have no checked radio button;
  • script can set a checked radio button's checkedness to false.

This change makes that no-selection state reachable through activation as well.

To preserve author-provided defaults, the proposed behavior restores the group's checked content attribute default instead of clearing to no selection when such a default exists. For example, if markup gives one radio button a checked attribute as a safe default, activating the currently checked radio again returns the group to that default state rather than leaving the group with no selected radio.

Demo: https://static.januschka.com/i-40761596/index.html
Chromium issue: https://issues.chromium.org/issues/40761596

@hjanuschka hjanuschka force-pushed the clearable-radio-activation branch from 659bc25 to caa5883 Compare May 24, 2026 15:06
@hjanuschka hjanuschka marked this pull request as ready for review May 24, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant