Repository navigation
[@mantine/core] Radio, Chip: Fix readOnly prop not preventing value changes - #9282
Merged
Merged
Conversation
… changes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
🤖 Beep boop, Claude (Fable 5.1) speaking! Here are changes I've made in this PR:
Verified in the browser: readOnly Radio and Chip (controlled, uncontrolled, inside Radio.Group and Chip.Group) do not change on click, Space or arrow keys and do not call |
Member
|
Thanks! |
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.
Bug
RadioandChipwithreadOnlycan still be changed by clicking. The prop goes to the native<input>, but browsers ignorereadonlyon radio and checkbox inputs. So clicking checks the input and callsonChange, in both controlled and uncontrolled mode.Checkboxalready handles this (#8960), andSwitchis being fixed in #9280.Fix
Same approach as
Checkbox:Radio: skiponChangeand theRadio.Groupcontext update whenreadOnly;preventDefault()on click when uncontrolled.Chip: skip the uncontrolled state update and theChip.Groupcontext update whenreadOnly.Testing
Radio.test.tsxandChip.test.tsxcover controlled, uncontrolled and inside a group. 6 fail on master and pass with the fix. The 7th checks that a controlled radio stays in sync with outside changes.oxlintandformat:write:filesare clean.🤖 Generated with Claude Code