Skip to content

fix(usePress): add global touch-action style for pressable elements #8200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 8, 2025

Conversation

reidbarber
Copy link
Member

@reidbarber reidbarber commented May 7, 2025

Closes #8086

Before:
Before change (Profiler shows 635.3 millisecond task)

After:
After change (Profiler shows 46.0 millisecond for same task)

✅ 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:

  1. Check that:
<style id="react-aria-pressable-style">@layer {
  :where([data-react-aria-pressable]) {
    touch-action: pan-x pan-y pinch-zoom;
  }
}</style>

is first style in head on pages containing one or more pressable elements (and is only added once per page).

(Given the page doesn't contain a meta viewport tag with width=device-width)

  1. Check the computed style of a pressable element to ensure it resolves to that touch-action style by default

  2. Check that we still avoid the onClick delay for double tap to zoom on touch devices (fix: Apply touch-action by default in usePress #8047)

🧢 Your Project:

@reidbarber reidbarber changed the title fixadd global touch-action style for pressable elements fix(usePress): add global touch-action style for pressable elements May 7, 2025
@rspbot
Copy link

rspbot commented May 7, 2025

@rspbot
Copy link

rspbot commented May 7, 2025

@rspbot
Copy link

rspbot commented May 7, 2025

@rspbot
Copy link

rspbot commented May 7, 2025

snowystinger
snowystinger previously approved these changes May 7, 2025
@rspbot
Copy link

rspbot commented May 7, 2025

@rspbot
Copy link

rspbot commented May 8, 2025

snowystinger
snowystinger previously approved these changes May 8, 2025
@rspbot
Copy link

rspbot commented May 8, 2025

Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

Tested original android reproduction in mobile emulation mode and confirmed it still works.

@reidbarber reidbarber added this pull request to the merge queue May 8, 2025
Merged via the queue into main with commit 2a2d571 May 8, 2025
30 checks passed
@reidbarber reidbarber deleted the usepress-touch-action-global branch May 8, 2025 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance degradation in onPress
5 participants