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-native-web: isImmediatePropagationStopped is not a function #7259

Closed
awinograd opened this issue Jun 3, 2021 · 12 comments · Fixed by #7286
Closed

react-native-web: isImmediatePropagationStopped is not a function #7259

awinograd opened this issue Jun 3, 2021 · 12 comments · Fixed by #7286

Comments

@awinograd
Copy link
Contributor

The event "polyfill" detection

if (!event || !event.isPropagationStopped) {

doesn't seem to be compatible with react-native-web's event system. isPropagationStopped is defined on MouseEvents (https://github.com/necolas/react-native-web/blob/66d01734ce3ffcfea61e05aa1b45015658b3f2af/packages/react-native-web/src/modules/createEventHandle/index.js#L69) but isImmediatePropagationStopped is not which causes the error isImmediatePropagationStopped is not a function to be thrown here:

if (event.isImmediatePropagationStopped()) {

@welcome
Copy link

welcome bot commented Jun 3, 2021

👋 Thanks for opening your first issue here! 👋

If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.

@kentferolino
Copy link

Are you able to solve this @awinograd ?

@awinograd
Copy link
Contributor Author

I applied the following patch with patch-package. It's worked well for me so far, but use at your own risk!

diff --git a/node_modules/video.js/dist/video.es.js b/node_modules/video.js/dist/video.es.js
index 94e1f35..3612ca6 100644
--- a/node_modules/video.js/dist/video.es.js
+++ b/node_modules/video.js/dist/video.es.js
@@ -2024,7 +2024,7 @@ function fixEvent(event) {
   // with the Javascript Ninja code. So we're just overriding all events now.
 
 
-  if (!event || !event.isPropagationStopped) {
+  if (!event || !event.isPropagationStopped || !event.isImmediatePropagationStopped) {
     var old = event || window.event;
     event = {}; // Clone the old object so that we can modify the values event = {};
     // IE8 Doesn't like when you mess with native event properties

@kentferolino
Copy link

Thanks for the suggestion @awinograd !

@kentferolino
Copy link

I got mine working using this snippet

  • if (event.isImmediatePropagationStopped()) {
  • if (event && event.isImmediatePropagationStopped && event.isImmediatePropagationStopped()) {

@gkatsev
Copy link
Member

gkatsev commented Jun 24, 2021

@awinograd care to submit a PR for this?

Seems like react-native-web basically implements a lot of the same type of events that we do, but it only implements isPropagationStopped but not isImmediatePropagationStopped. This means that we do want to "fix" this event into our event system.

@necolas
Copy link

necolas commented Jun 24, 2021

preact/compat also adds isPropagationStopped to native events as part of emulating React synthetic events. It's not great, and I don't think this library should be emulating React's synthetic event extensions either.

@gkatsev
Copy link
Member

gkatsev commented Jun 24, 2021

Yeah, everyone is basically following jQuery's lead here hehe

@awinograd
Copy link
Contributor Author

I'm happy to open a PR. Though I do agree with @necolas in that this event emulation is pretty fragile. Unfortunately I dont have much to contribute towards a better solution in that regard.

@gkatsev
Copy link
Member

gkatsev commented Jun 24, 2021

It's been working (mostly) great for us for years, though, yeah, it's definitely not great.
At some point, maybe we'll find the time to see if we can rip out the entire event system and only rely on native events. But for now, we're stuck.
A PR would be appreciated!

@awinograd
Copy link
Contributor Author

@gkatsev I definitely understand the need to find the right balance! Thanks for all your work on the library. I've opened a PR as requested.

#7286

@gkatsev
Copy link
Member

gkatsev commented Jun 24, 2021

Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2022
edirub pushed a commit to edirub/video.js that referenced this issue Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants