Skip to content
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

chore: remove ontouchstart event from buttons #3746

Merged
merged 3 commits into from
Jan 28, 2025

Conversation

enesozturk
Copy link
Contributor

@enesozturk enesozturk commented Jan 27, 2025

Description

We are using ontouchstart event on almost all buttons in our UI components. This is an example of inline function calling in JS, and browsers' Content Security Policy does not allow inline javascript.

This is resulting getting an error like:

Refused to execute inline event handler because it violates the following Content Security Policy directive...

Why we have ontouchstart

This property comes from the early times of the web3modal, very old changes and there is no obvious reason to have it. As my research GPT says something that performance optimization on the mobile:

When you add a ontouchstart listener, many browsers apply a performance optimization on mobile devices. By enabling the ontouchstart event, the browser may eliminate the 300ms delay that is typically associated with the click event. This delay exists to detect double-tap gestures, but when ontouchstart is present, the browser assumes the element is optimized for touch and skips the delay, leading to a faster and more responsive user experience

But this is not accurate that there is no info on internet about this hack. Even though we have, we should follow native priciples of web development and shouldn't go for this hack, as it's also causing CSP issues.

This PR introduces changes to button's to remove ontouchstart from our buttons.

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

For Linear issues: Closes APKT-2132
For GH issues: closes #...

Showcase (Optional)

If there is a UI change include the screenshots with before and after state.
If new feature is being introduced, include the link to demo recording.

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Copy link

changeset-bot bot commented Jan 27, 2025

🦋 Changeset detected

Latest commit: 3f12a85

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
@reown/appkit-scaffold-ui Patch
@reown/appkit-ui Patch
@reown/appkit-adapter-bitcoin Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-wagmi Patch
@reown/appkit Patch
@reown/appkit-utils Patch
@reown/appkit-cdn Patch
@reown/appkit-cli Patch
@reown/appkit-common Patch
@reown/appkit-core Patch
@reown/appkit-experimental Patch
@reown/appkit-polyfills Patch
@reown/appkit-siwe Patch
@reown/appkit-siwx Patch
@reown/appkit-wallet Patch
@reown/appkit-wallet-button Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jan 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
appkit-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 5:35am
appkit-laboratory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 5:35am
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
appkit-vue-solana ⬜️ Ignored (Inspect) Jan 28, 2025 5:35am
appkit-wagmi-cdn-example ⬜️ Ignored (Inspect) Jan 28, 2025 5:35am
vue-wagmi-example ⬜️ Ignored (Inspect) Jan 28, 2025 5:35am

Copy link
Contributor

github-actions bot commented Jan 27, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 68.25% 19607 / 28725
🔵 Statements 68.25% 19607 / 28725
🔵 Functions 59.5% 1718 / 2887
🔵 Branches 79.9% 3488 / 4365
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/scaffold-ui/src/partials/w3m-all-wallets-list-item/index.ts 93.93% 96% 100% 93.93% 69, 86, 95-96
packages/scaffold-ui/src/partials/w3m-onramp-provider-item/index.ts 16.21% 100% 0% 16.21% 12-27, 31-53, 57-73
packages/ui/src/composites/wui-button/index.ts 100% 100% 100% 100%
packages/ui/src/composites/wui-card-select/index.ts 9.09% 100% 0% 9.09% 15-66
packages/ui/src/composites/wui-compatible-network/index.ts 13.63% 100% 0% 13.63% 14-45
packages/ui/src/composites/wui-connect-button/index.ts 100% 100% 100% 100%
packages/ui/src/composites/wui-icon-link/index.ts 100% 50% 100% 100%
packages/ui/src/composites/wui-link/index.ts 100% 100% 100% 100%
packages/ui/src/composites/wui-list-accordion/index.ts 4.81% 100% 0% 4.81% 15-118
packages/ui/src/composites/wui-list-button/index.ts 100% 100% 100% 100%
packages/ui/src/composites/wui-list-description/index.ts 100% 100% 100% 100%
packages/ui/src/composites/wui-list-item/index.ts 89.83% 68.18% 100% 89.83% 62-63, 65-66, 85-86
packages/ui/src/composites/wui-list-network/index.ts 8.33% 100% 0% 8.33% 12-61
packages/ui/src/composites/wui-list-social/index.ts 92.3% 75% 100% 92.3% 50-51
packages/ui/src/composites/wui-list-token/index.ts 92.3% 75% 100% 92.3% 53-54
packages/ui/src/composites/wui-list-wallet/index.ts 84.61% 84.21% 100% 84.61% 57, 67-72, 84-85
packages/ui/src/composites/wui-logo-select/index.ts 100% 100% 100% 100%
packages/ui/src/composites/wui-profile-button/index.ts 93.75% 42.85% 100% 93.75% 59-60
packages/ui/src/composites/wui-profile-button-v2/index.ts 75% 28.57% 50% 75% 66-72, 76-84
packages/ui/src/composites/wui-promo/index.ts 27.27% 100% 0% 27.27% 12-24
packages/ui/src/composites/wui-token-button/index.ts 85% 75% 100% 85% 36-44
packages/ui/src/composites/wui-wallet-button/index.ts 100% 90.9% 100% 100%
Generated in workflow #9154 for commit 3f12a85 by the Vitest Coverage Report Action

Copy link

linear bot commented Jan 28, 2025

@enesozturk enesozturk merged commit 171b8ae into main Jan 28, 2025
19 checks passed
@enesozturk enesozturk deleted the chore/remove-ontouchstart-event-from-comps branch January 28, 2025 06:33
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