Skip to content

[Web] Align Tap maxDelay default with native (200 ms) - #4557

Open
Shexter wants to merge 1 commit into
software-mansion:mainfrom
Shexter:fix-web-tap-max-delay-default
Open

Shexter wants to merge 1 commit into
software-mansion:mainfrom
Shexter:fix-web-tap-max-delay-default

Conversation

@Shexter

@Shexter Shexter commented Oct 1, 2026

Copy link
Copy Markdown

Description

The default for Tap's maxDelay (how long the handler waits for the next tap when numberOfTaps > 1) was 500 ms on web but 200 ms on Android and Apple, so the same useTapGesture({ numberOfTaps: 2 }) behaved differently per platform:

Platform Default Location
Web 500 ms src/web/handlers/TapGestureHandler.ts:10
Android 200 ms android/.../core/TapGestureHandler.kt:190
Apple 200 ms apple/Handlers/RNTapHandler.m:51

As discussed in #4555, 200 ms is the intended default, since it is the value chosen for mobile. This PR changes web to 200 ms and updates the places that stated 500 ms: the useTapGesture docs page and the maxDelay comments in TapTypes.ts and the v1 TapGestureHandler.ts. The 1.x and 2.x versioned docs are untouched.

Behaviour change: on web, a multi-tap now fails if the next tap takes longer than 200 ms, unless maxDelay is set explicitly. Setting it keeps working as before.

Discussion: #4555

Test plan

Added src/web/handlers/__tests__/TapGestureHandler.test.ts, which uses fake timers with numberOfTaps: 2, lands the first tap and lets time pass:

  • with no config, the handler fails after 300 ms (delegate.onFail is called)
  • it does not fail after 100 ms
  • an explicit maxDelayMs: 500 still keeps it alive at 300 ms
  • a config without maxDelayMs restores the default after one that set it

With the constant set back to 500, the two tests that depend on the default fail. With 200, all four pass.

Run in packages/react-native-gesture-handler:

  • yarn test: 22 suites, 182 tests passed
  • yarn ts-check: exit 0
  • yarn lint:js: exit 0, 0 errors

The change is web and docs only, so I did not run Android or iOS builds.

Copilot AI balanced review requested due to automatic review settings October 1, 2026 19:59
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 41ee5baf-fb5a-420e-9f00-abaf2f242213

📥 Commits

Reviewing files that changed from the base of the PR and between 3f01ff6 and 648719a.

📒 Files selected for processing (5)
  • packages/docs-gesture-handler/docs/gestures/use-tap-gesture.mdx
  • packages/react-native-gesture-handler/src/handlers/TapGestureHandler.ts
  • packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/TapTypes.ts
  • packages/react-native-gesture-handler/src/web/handlers/TapGestureHandler.ts
  • packages/react-native-gesture-handler/src/web/handlers/__tests__/TapGestureHandler.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Updates
    • Web tap gestures now use a 200 ms default delay between successive taps, reduced from 500 ms.
    • Updated tap gesture documentation to reflect the 200 ms default delay.
  • Tests
    • Added coverage for default and custom tap delays, including how gestures respond when the delay expires.

Walkthrough

The web tap handler’s default inter-tap delay changes from 500 ms to 200 ms. Documentation states the updated default, and web tests check default and configured delay behavior.

Changes

Tap Gesture Delay

Layer / File(s) Summary
Update the tap delay default
packages/react-native-gesture-handler/src/web/handlers/TapGestureHandler.ts, packages/docs-gesture-handler/docs/gestures/use-tap-gesture.mdx, packages/react-native-gesture-handler/src/handlers/TapGestureHandler.ts, packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/TapTypes.ts
The web handler’s default inter-tap delay changes from 500 ms to 200 ms. Related documentation states a 200 ms default.
Test default and configured delays
packages/react-native-gesture-handler/src/web/handlers/__tests__/TapGestureHandler.test.ts
Fake-timer tests check the default delay and an explicit 500 ms setting.

Suggested reviewers: m-bert

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 64871

The web multi-tap default becomes 200 ms, while explicit delay settings retain their behavior. No actionable merge-blocking risk is identified; merge after normal checks.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 64871

The change shortens the default waiting period without expanding access or authority. Explicit timeout settings remain effective, and the existing failure and cleanup paths are preserved. No material security risk was identified in the changed behavior.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure change is limited to the timing of local web multi-tap recognition for callers using the default. The scoped runtime change introduces no new event source, configuration field, or privileged operation.

Trust Boundaries and Controls

  • inferred — Pointer input still reaches the existing gesture transition methods. The shorter delay invokes the same failure and cleanup path rather than bypassing a boundary or gaining additional callback authority.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: updating the web Tap gesture maxDelay default to 200 ms to match native behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/docs-gesture-handler/docs/gestures/use-tap-gesture.mdx

Oops! Something went wrong! :(

ESLint: 10.11.0

TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///.eslintrc.json?mtime=1790884801969" needs an import attribute of "type: json"
at validateAttributes (node:internal/modules/esm/assert:88:15)
at defaultLoadSync (node:internal/modules/esm/load:164:3)
at #loadAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:776:12)
at #loadSync (node:internal/modules/esm/loader:796:49)
at ModuleLoader.load (node:internal/modules/esm/loader:762:26)
at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:504:31)
at #getOrCreateModuleJobAfterResolve (node:internal/modules/esm/loader:555:36)
at afterResolve (node:internal/modules/esm/loader:603:52)
at ModuleLoader.getOrCreateModuleJob (node:internal/modules/esm/loader:609:12)
at node:internal/modules/esm/loader:628:32

packages/react-native-gesture-handler/src/handlers/TapGestureHandler.ts

ESLint skipped: the matched ESLint configuration already failed (config-incompatibility).

packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/TapTypes.ts

ESLint skipped: the matched ESLint configuration already failed (config-incompatibility).

  • 2 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused change includes regression coverage, preserves explicit overrides, and has no identified blocking issues.

Review effort: Balanced
Findings: None

What changed in this PR

Aligns web Tap’s default inter-tap delay with Android and Apple at 200 ms, while preserving explicit overrides.

Changes:

  • Changes the web default from 500 ms to 200 ms.
  • Adds regression tests for timing, overrides, and configuration resets.
  • Updates current documentation and API comments; versioned docs remain unchanged.
File Description
packages/​react-native-gesture-handler/​src/​web/​handlers/​TapGestureHandler.ts Sets the default delay to 200 ms.
packages/​react-native-gesture-handler/​src/​web/​handlers/​__tests__/​TapGestureHandler.test.ts Tests default timing, overrides, and resets.
packages/​react-native-gesture-handler/​src/​v3/​hooks/​gestures/​tap/​TapTypes.ts Corrects the v3 default-value comment.
packages/​react-native-gesture-handler/​src/​handlers/​TapGestureHandler.ts Corrects the legacy API default-value comment.
packages/​docs-gesture-handler/​docs/​gestures/​use-tap-gesture.mdx Documents the 200 ms default.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@m-bert m-bert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for this PR! ❤️

I don't think the test file is necessary, other than that looks good!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think changing one constant requires whole new test file 😅

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants