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

React Events: consolidate logic for Press event component #15451

Merged
merged 3 commits into from
Apr 19, 2019

Conversation

necolas
Copy link
Contributor

@necolas necolas commented Apr 19, 2019

Stacks on #15449. Demo integrating this patch: https://fburl.com/nfye4390

Refactor of Press and additional regression coverage.

  1. The logic for "start", "move", "end", and "cancel" events is consolidated into a single block to reduce duplication and improve consistency of the UX across input-types. Also reduces code size.

  2. The bailout logic for anchor tags is removed since we preventDefault for click by default. We can discuss scenarios where it makes sense to limit functionality around interactions on anchor tags.

  3. The logic for ignoring emulated events is simplified and improved. Pointer events can produce emulated touch (immediately after pointer) and mouse events (delayed) which is now accounted for and tested.

Ref #15257

Copy link
Contributor

@trueadm trueadm left a comment

Choose a reason for hiding this comment

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

Nice savings in code size. Also CI is failing too for some reason.

@necolas
Copy link
Contributor Author

necolas commented Apr 19, 2019

Added a link to an interactive demo running this patch. Will start doing this for most PRs that can benefit from reviewers checking interactions for themselves.

@necolas necolas force-pushed the react-events/press-consolidation branch from 6124563 to a6c3bc7 Compare April 19, 2019 15:50
@sizebot
Copy link

sizebot commented Apr 19, 2019

Details of bundled changes.

Comparing: 5857c89...a6c3bc7

react-events

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-events.production.min.js 0.0% -0.2% 857 B 857 B 477 B 476 B UMD_PROD
react-events.development.js 0.0% +0.2% 1.4 KB 1.4 KB 624 B 625 B NODE_DEV
react-events-press.development.js -13.7% -6.3% 20.45 KB 17.64 KB 4.77 KB 4.47 KB UMD_DEV
react-events-press.production.min.js -12.5% -4.0% 7.75 KB 6.78 KB 2.64 KB 2.54 KB UMD_PROD
react-events-press.development.js -13.8% -6.5% 20.28 KB 17.47 KB 4.73 KB 4.43 KB NODE_DEV
react-events-press.production.min.js -12.8% -4.1% 7.58 KB 6.61 KB 2.59 KB 2.49 KB NODE_PROD
ReactEventsPress-dev.js -16.0% -8.4% 18.51 KB 15.54 KB 4.03 KB 3.69 KB FB_WWW_DEV
ReactEventsPress-prod.js -17.5% -6.5% 15.55 KB 12.84 KB 3.01 KB 2.82 KB FB_WWW_PROD
react-events-hover.development.js 0.0% -0.0% 8.29 KB 8.29 KB 2.07 KB 2.07 KB UMD_DEV
react-events-hover.production.min.js 0.0% -0.1% 3.54 KB 3.54 KB 1.3 KB 1.29 KB UMD_PROD
react-events-hover.development.js 0.0% -0.0% 8.12 KB 8.12 KB 2.03 KB 2.03 KB NODE_DEV
react-events-hover.production.min.js 0.0% -0.1% 3.38 KB 3.38 KB 1.25 KB 1.24 KB NODE_PROD
react-events-focus.development.js 0.0% -0.1% 4.06 KB 4.06 KB 1.33 KB 1.33 KB UMD_DEV
react-events-focus.production.min.js 0.0% -0.1% 1.65 KB 1.65 KB 788 B 787 B UMD_PROD
react-events-focus.development.js 0.0% -0.1% 3.89 KB 3.89 KB 1.29 KB 1.29 KB NODE_DEV
react-events-focus.production.min.js 0.0% -0.3% 1.49 KB 1.49 KB 724 B 722 B NODE_PROD
react-events-swipe.development.js 0.0% -0.0% 8.43 KB 8.43 KB 2.63 KB 2.62 KB UMD_DEV
react-events-swipe.production.min.js 0.0% -0.1% 3.46 KB 3.46 KB 1.61 KB 1.61 KB UMD_PROD
react-events-swipe.development.js 0.0% -0.0% 8.26 KB 8.26 KB 2.59 KB 2.59 KB NODE_DEV
react-events-swipe.production.min.js 0.0% -0.1% 3.3 KB 3.3 KB 1.55 KB 1.55 KB NODE_PROD
react-events-drag.development.js 0.0% -0.0% 7.96 KB 7.96 KB 2.51 KB 2.51 KB UMD_DEV
react-events-drag.development.js 0.0% -0.0% 7.79 KB 7.79 KB 2.47 KB 2.47 KB NODE_DEV

Generated by 🚫 dangerJS

@necolas necolas merged commit 051513b into facebook:master Apr 19, 2019
@necolas necolas deleted the react-events/press-consolidation branch May 3, 2019 17:34
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.

4 participants