Skip to content

Conversation

@yihuiliao
Copy link
Member

@yihuiliao yihuiliao commented Jan 2, 2026

Closes #9425

We do this in useToggle for Checkbox/CheckboxGroup

isDisabled: isDisabled || isReadOnly
so the logic is similar

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@yihuiliao yihuiliao marked this pull request as ready for review January 2, 2026 17:46
@rspbot
Copy link

rspbot commented Jan 2, 2026

let label = getAllByRole('radio')[0].closest('label');

expect(group).toHaveAttribute('aria-readonly');
expect(group).toHaveClass('readonly');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a little weird, and possibly a different issue, why are the group and the label both getting the readonly class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just copied that from the previous test to confirm the ready only part so different issue?

onPressUp,
onClick,
isDisabled,
isDisabled: isDisabled || state.isReadOnly,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh... useToggle seems more like the bug, it was done to prevent us from allowing the value to be changed by our manual handling, it wasn't done to prevent onPress from being called.

I would argue that onPress should be called, interactions aren't prevented by readonly, for example, an input. You can click into those and select and copy text. You just can't change it. I'll ask a question in the Issue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm yeah i think that's a valid argument. fine to close this issue if we think it this is the correct behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Radio#onPress should not be triggered with RadioGroup#isReadOnly

4 participants