Skip to content

fix(switch): #5222 followup - does not warn when readOnly is set without onValueChange test fix - #5240

Open
jacekAtCK wants to merge 1 commit into
callstack:mainfrom
jacekAtCK:fix/switch-review-followups
Open

jacekAtCK wants to merge 1 commit into
callstack:mainfrom
jacekAtCK:fix/switch-review-followups

Conversation

@jacekAtCK

Copy link
Copy Markdown
Collaborator

Motivation

Follow-up to #5222, from the review in #5222 (comment).

The test "does not warn when readOnly is set without onValueChange" failed when it ran by itself. The first Switch render in a Jest worker also logs the one-time Reanimated warnings, so console.warn got 4 calls. The test now checks only for the Switch: warning, so the result does not depend on the order of the tests.

This PR also makes the four smaller changes from the same review:

  • An operable Switch on web no longer renders aria-readonly="false". The attribute is set only when the switch is read-only.
  • A Switch on web that cannot be operated hides the outline of the browser. Before, a switch that had keyboard focus when it became read-only kept DOM focus and showed the default browser outline. This also applies to a disabled switch.
  • The read-only switch in the example app has aria-label="Read-only", so a screen reader has a name to announce.
  • The props of TertiarySwitch in the migration guide are typed, so the snippet compiles under strict.

Related issue

Follow-up to #5222.

Screenshots / Videos

No visual change, except that the browser outline does not show in the case above.

Test plan

In the Switch example on web:

  1. Inspect an operable switch. It has no aria-readonly attribute.
  2. Inspect the read-only switch. It has aria-readonly="true".
  3. Turn on VoiceOver and move to the read-only switch. VoiceOver announces "Read-only" and the switch state.

@github-actions

Copy link
Copy Markdown

Found potential problems with the pull request:

  • The description is too long. Please keep it under 1000 characters.
  • Screenshot or video evidence is missing. Make sure to include one if it affects the UI.

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 3 new findings on 9924209. The verdict and the full list are in the summary comment.

Comment thread src/components/Switch/Switch.tsx Resolved
Comment thread src/components/Switch/Switch.tsx Resolved
@jacekAtCK

Copy link
Copy Markdown
Collaborator Author

/review

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 9924209

Re-run on the same commit.

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
src/components/Switch/Switch.tsx:465 Focused non-interactive switch on web loses its only focus indicator (disabled too, not just readOnly)

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (c8c3a3945ccb).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant