radio: Keep a disabled Radio disabled inside a RadioGroup - #3331
Open
Bombatomica64 wants to merge 1 commit into
Open
Bombatomica64 wants to merge 1 commit into
Bombatomica64 wants to merge 1 commit into
Conversation
RadioGroup applied its own disabled flag to every child, overwriting a Radio's .disabled(true), so a disabled option looked enabled and could be selected. Combine the two: an item is disabled if it or the group is. Closes longbridge#3324 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Sep 30, 2026
Open
Contributor
Author
|
I've added before/after screen recordings to the Screenshot section (Android, dark theme, Kit 0.7.0 with and without this diff; tapping XL (disabled), M, then XL). Before pr3331-before.mp4After pr3331-after.mp4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3324
Description
RadioGroup::renderapplied the group'sdisabledflag to every child withradio.disabled(disabled), which overwrote a Radio's own.disabled(true). A disabled option in an enabled group looked enabled and could be selected.An item is now disabled when it or the group is:
radio.disabled(disabled || item_disabled). A disabled group still disables every item.Screenshot
Screen recordings on Android (Redroid, dark theme) of a
RadioGroupwhose "XL" item is.disabled(true), tapping XL, then M, then XL, Kit 0.7.0 with and without this diff.Before
pr3331-before.mp4
After
pr3331-after.mp4
Before: XL renders enabled and each tap selects it (
horizontal=Some(3)). After: XL renders disabled and taps do nothing, while M still selects normally.Builds: demo-pr3331.
How to Test
radio_group_keeps_a_disabled_item_disabledincrates/kit/tests/controls.rs: clicking a disabled item in an enabled group leaves the selection unchanged, clicking an enabled item selects it, and in a disabled group an enabled item cannot be selected. Onmainit fails with the disabled item selected (Some(1)).cargo test -p gpui-kit --features test-support,component --test controls: 8 passed.cargo test -p gpui-component --features test-support --lib radio: 2 passed.Note: I first tried to assert on
TestElement::disabled(), but it is not populated for Radio or Checkbox (the existinglockedCheckbox test also expectsNone), so the test checks behaviour instead.Checklist
cargo runfor story tests related to the changes. (Not run: no desktop session here; see How to Test.)Thanks for taking the time to review this.
🤖 Generated with Claude Code