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

fix(brush): use PointerEvents instead of MouseEvents #1155

Merged
merged 2 commits into from
Apr 13, 2021

Conversation

RemaaBdair
Copy link
Contributor

I opened this pr with the same changes as in this one #864, but with addressing the reviews as well in order to speed things up.

💥 Breaking Changes

  • none

🚀 Enhancements

📝 Documentation

🐛 Bug Fix

🏠 Internal

Copy link
Collaborator

@williaster williaster left a comment

Choose a reason for hiding this comment

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

Thanks for starting a new PR for this long-standing fix @RemaaBdair ! 🙏

I had one suggestion to simplify but otherwise looks good to me. Note, too, that it is currently failing our prettier linting. I think after my suggested changes it may want the type definitions to each be on a single line. You should be able to run yarn format in your visx root directory to fix it after the suggested changes, and then commit any changes that come from running that.

@@ -10,9 +10,10 @@ import { MarginShape, Point, BrushShape, ResizeTriggerAreas, PartialBrushStartEn

const BRUSH_OVERLAY_STYLES = { cursor: 'crosshair' };

type MouseHandlerEvent =
type PointerHandlerEvent =
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think all of this can be simplified to React.PointerEvent<SVGRectElement>, which is already equivalent to MouseEvent | TouchEvent

type MouseHandler = (
event: React.MouseEvent<SVGRectElement, MouseEvent> | React.TouchEvent<SVGRectElement>,
type PointerHandler = (
event: React.MouseEvent<SVGRectElement, MouseEvent> | React.TouchEvent<SVGRectElement> | React.PointerEvent<SVGRectElement>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment here

Suggested change
event: React.MouseEvent<SVGRectElement, MouseEvent> | React.TouchEvent<SVGRectElement> | React.PointerEvent<SVGRectElement>,
event: React.PointerEvent<SVGRectElement>,

@williaster williaster changed the title change mouse events to pointer events to support touch events on mobile devices fix(brush): use PointerEvents instead of MouseEvents Apr 13, 2021
Copy link
Collaborator

@williaster williaster left a comment

Choose a reason for hiding this comment

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

Amazing, thanks for the fix @RemaaBdair !

@williaster williaster merged commit d70c524 into airbnb:master Apr 13, 2021
@github-actions
Copy link

🎉 This PR is included in version v1.7.4 of the packages modified 🎉

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.

2 participants