-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Support Pointer Events #12507
Support Pointer Events #12507
Conversation
Nice! I think a polyfill is probably not needed here. In general we are trying to less of that to simplify and shrink react-dom |
b132e7f
to
da440d7
Compare
This PR adds a section about the state of Pointer Events in React. This should be merged only if facebook/react#12507 is accepted as well.
ReactDOM: size: 🔺+0.9%, gzip: 🔺+0.7% Details of bundled changes.Comparing: de84d5c...5f3167d react-dom
Generated by 🚫 dangerJS |
I don’t think we can afford to increase the bundle size with more events, at least not now. If we want to do this we need to find something to cut. |
@gaearon Thanks for looking into that! Any ideas where/how we can loose some weight? |
No more adding any events? Or polyfill? I think react DOM has a responsibility to support the new things in the platform as much as it has one to web perf. Not mention adding new events without bundle increases will likely require a rewrite of the event system. The latter is going to take a long time and involve a lot of input across renderers and FB in general, I hate for RD to fall behind in platform support in the meantime. |
I’m not saying to never add them. But this is adding a lot.
I think that might be an overstatement. To drop the 1K pre-gzip, we need to find a way to drop the 1K pre-gzip. Not necessarily rewrite the event system. It could be composed of small improvements anywhere. We get a lot of PRs with features. I appreciate this but I think it's time more people start hunting for opportunities to cut the size if we want to ship those features.
I tend to start by running Here are some examples of me doing it: #11912 #11800 #10803 #10802 #10671 #10227. There was no specific pattern other than I looked through all the bundle code, found dubious logic, and deleted or refactored it. |
To clarify the previous comment. I don’t mean we need to find a way to add events without increasing the whitelist right now (although that would be nice). I mean that if we want to add something, we need to start being more proactive at removing something. Even if those things are not directly related. This applies both to the core team and to the outside contributions. |
Sorry, it's an overstatement if the idea is we should find anything to remove. I do think this PR illustrates that long term, the current system is not great, if we don't want to increase the bundle size as the platform grows. I'd love to start making incremental improvements to the events, (as well as @nhunzaker tho we've both been short on time :/ ). I would say tho, that our explorations there, indicate tho that incremental improvements are hard there, as the whole system sort of neatly rests on itself. Maybe on that front we could do another small call and debrief a bit out it and chart a way forward.
Ya that's great, We should and definitely start building an environment of trimming down the code. I'm just a bit worried about the added outside cost. This adds an even steeper hill to outside contributors, in already hard-to-contribute-to code base. Finding things that are safe to delete requires a lot of experience in the codebase, and as a point of contribution, it's a lot harder to get reviews for those sort of changes. I totally understand the sentiment i just want to make sure we aren't pushing folks away from submitting good additions, because they can't cut an equal amount out somewhere. |
Agreed! Rewriting it is a very ambitious goal that also has downstream effects (e.g.
I’m always happy to review bundle size improvements outside of the normal queue. I agree it's not easy but it's necessary. |
I think identifying if we can move forward with #11894 would be a good opportunity to reduce bundle size. |
I won't have time to do it but happy to review. |
Is the idea that any bundle size increase at all is a blocker? Or only above a certain absolute size, or is there a % threshold? |
I'm uncomfortable adding non-core features that increase size at the same time as we're working on core features that will also increase the size. It's not that there's any particular change or a size limit, but the fact that we get very few pull requests that remove code. So every non-core feature contributes to a death by a thousands cuts. There was a lot of hard work to get the bundle size down with 16 (partially to “free the space” for new features) and the bar for taking unplanned changes that increase the size is becoming higher now. That can be mitigated with proactive work on getting it down again, but it requires some investment. |
@philipp-spiess Can you please rebase so we can land this? Thanks! |
9548c1c
to
5f3167d
Compare
🎉 The PR is now rebased against my changes from #12629. I've updated the DOM fixture as well to reflect the example we also use for the I tested the using the DOM fixture against the following browsers to make sure everything works as expected:
However I did find an issue while testing with PEP in Safari 11. According to MDN, I assume that proper support would need code added in I think it's a better tradeoff to not fully support PEP for now, hence I've removed the mention of PEP in the parallel guide article (reactjs/react.dev#792). It's still possible to use PEP by adding custom event handler to the DOM node. Maybe this is something we want to mention in the docs? |
This looks good to me. |
(To add context to my earlier comments, @philipp-spiess made a pretty big refactoring to save some bytes in #12629. So that's why I'm comfortable taking this now. :-) |
woohoo! Thanks ya'll |
This is based on facebook/react#12507 which is seemingly missing a couple of fields from the official spec. Consequently this will need an update once React supports all fields.
While working on facebook/flow#6728 I noticed React's recently-added `SyntheticPointerEvent` was missing the [`tangentialPressure`](https://www.w3.org/TR/pointerevents/#dom-pointerevent-tangentialpressure) and [`twist`](https://www.w3.org/TR/pointerevents/#dom-pointerevent-twist) fields. I couldn't find any reason for their omission in #12507 (nor in the spec) so I assume they were meant to be included, like the rest of `PointerEvent`. This PR adds these two fields to `SyntheticPointerEvent`.
This is based on facebook/react#12507 which is seemingly missing a couple of fields from the official spec. Consequently this will need an update once React supports all fields.
Summary: Closes #6373, closes #3227. The definition of `SyntheticPointerEvent` here was originally based on facebook/react#12507 (released in React DOM 16.4.0) which was missing a couple of fields (`twist` and `tangentialPressure`) from the official spec. I've now updated this branch to include those fields, since facebook/react#13374 has been merged. However, for maximum correctness we should probably wait for that to be _released_ before releasing the corresponding type definitions. I'll update this notice once the relevant React DOM release happens. Pull Request resolved: #6728 Reviewed By: fishythefish Differential Revision: D9338459 Pulled By: mrkev fbshipit-source-id: 263f4922e8a6765e4a2d6553b5af785bdc65a894
This is based on facebook/react#12507 which is seemingly missing a couple of fields from the official spec. Consequently this will need an update once React supports all fields.
This is based on facebook/react#12507 which is seemingly missing a couple of fields from the official spec. Consequently this will need an update once React supports all fields.
This PR adds a section about the state of Pointer Events in React. This should be merged only if facebook/react#12507 is accepted as well.
* Add section about Pointer Events This PR adds a section about the state of Pointer Events in React. This should be merged only if facebook/react#12507 is accepted as well. * Don’t recommend PEP because it lacks features
This is based on facebook/react#12507 which is seemingly missing a couple of fields from the official spec. Consequently this will need an update once React supports all fields.
Closes #499
This PR adds support for Pointer Events as discussed in #499. It is heavily based on previous work in #1389 and will add most pointer events to the
SimpleEventPlugin
and enter/leave events toEnterLeaveEventPlugin
.I added a new DOM fixture to test all pointer events and make sure my implementation does indeed work. I tested on Chrome 65 and Firefox 59 without seeing any issues. If you think the fixtures is not necessary for future changes, I'm happy to remove them as well.
The only open question is if we want to add a polyfill. For the sake of simplicity, I opted against a polyfill for this PR. However, this work is compatible with PEP (I've verified this behavior in Safari 11 by loading PEP in
fixtures/dom/public/index.html
).