react: Bug: Quickly selecting checkboxes on iOS doesn't work correctly

React version: 18.0.0 and 17.0.2

Steps To Reproduce

  1. Open https://4txdx2.csb.app/ (React 18) in a device running iOS in Safari / Chrome.
  2. Quickly tap one checkbox followed by another one.
  3. Notice that if you quickly select one checkbox followed by another one, it checks / unchecks the previous checkbox you were on on.

Link to code example:

React 18.0.0 Sandbox, Preview

React 17.0.2 Sandbox, Preview

React 16.4.0 Sandbox, Preview

The current behavior

There appears to be some sort of race condition where tapping on a controlled / uncontrolled <input type="checkbox"> quickly after tapping another checkbox updates the original checkbox you tapped rather than the checkbox that was just tapped. It appears to be a timing issue - if you wait long enough between taps, the events are fired on the correct elements.

This works in React 16 but not React 17 and 18.

The expected behavior

The checkbox state should reflect the checked state of the checkbox you tapped, not the previous checkbox you tapped.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 5
  • Comments: 18 (1 by maintainers)

Most upvoted comments

I have the same issue on a regular button to increase or decrease a value (-) (+). If you spam click it will only update once and never again until you take a break and click again. Feels that there’s like a 500ms throttle or something to not cause multiple clicks by mistake, but when that’s what you want, what do you do then?

touch-action: manipulation; didn’t do anything to help for me.

I just tested it on 19.0.0-beta-26f2496093-20240514 react and react-dom and the issue still exists.

Just want to make sure that this original issue that I referenced in my issue is linked here too: #27475

This seems like a pretty basic flaw in React, so I don’t want it to get auto-closed for no activity. How do we get maintainers to acknowledge this issue?

The fix in my previous comment only works when you zoom in on your mobile device. If you’re zoomed out, it does’t work.