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

SwipeableDrawer JS error when dragging it, [Intervention] canceling event #12094

Closed
2 tasks done
jlascoleassi opened this issue Jul 9, 2018 · 13 comments
Closed
2 tasks done
Labels
bug 🐛 Something doesn't work component: drawer This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@jlascoleassi
Copy link
Contributor

  • This is a v1.x issue (v0.x is no longer maintained).
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

I would expect to not see JS errors build up in the console

Current Behavior

When dragging the SwipeableDrawer, a JS error is continuously thrown in the console:
"[Intervention] Ignored attempt to cancel a touchmove event with cancelable=false, for example because scrolling is in progress and cannot be interrupted."

Steps to Reproduce (for bugs)

  1. Use SwipeableDrawer in a project
  2. Open inspector console
  3. Once it's open, drag it slowly, in either direction
  4. You will notice a JS error for every drag movement

Context

A lot of JS errors are thrown

Your Environment

Tech Version
Material-UI v1.3.0
React 16.2.0
browser Chrome, iOS Simulator
etc

Potential Solution

After searching a bit online, others who have had similar errors have suggested checking to see if the event is cancelable before trying to cancel it. I modified the local code to test this out and the solution seems to work without any side effects. This solution would be:

Around line 155, add the && to check if the event is cancelable before preventing default:
if (dx > dy && event.cancelable) {
event.preventDefault();
}

And around line 188, do the same here:
if (event.cancelable) {
event.preventDefault();
}

@oliviertassinari oliviertassinari added the component: drawer This is the name of the generic UI component, not the React module! label Jul 17, 2018
@oliviertassinari oliviertassinari self-assigned this Jul 28, 2018
@oliviertassinari
Copy link
Member

@jlascoleassi Something is definitely off. Thanks for raising it.
I know I have been fixing such issue on react-swipeable-views at some point, but I can't remember how.

@oliviertassinari oliviertassinari added good first issue Great for first contributions. Enable to learn the contribution process. bug 🐛 Something doesn't work labels Jul 29, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 29, 2018

Alright, after some digging, I think that I have found a good trail. I went back to @RByers comment on oliviertassinari/react-swipeable-views#183 (comment). We can leverage the touch-action: none; CSS style to disable the scrolling on the Backdrop. This consistently make the warning disappear.

@jlascoleassi Do you want to work on it? The following diff in the Backdrop.js should be enough:

  root: {
    zIndex: -1,
    position: 'fixed',
    right: 0,
    bottom: 0,
    top: 0,
    left: 0,
    backgroundColor: 'rgba(0, 0, 0, 0.5)',
    // Remove grey highlight
    WebkitTapHighlightColor: 'transparent',
+   // Disable scroll capabilities.
+   touchAction: 'none',
  },

@jlascoleassi
Copy link
Contributor Author

@oliviertassinari I just created the pull request and believe I took the appropriate steps for contributing. If not, please let me know. Thank you very much!

@9jaGuy
Copy link

9jaGuy commented Sep 21, 2018

I still see this conole error on Chrome Device emulator for SwipeableDrawer

@oliviertassinari
Copy link
Member

@9jaboy are you using the latest version of Material-UI?

@9jaGuy
Copy link

9jaGuy commented Sep 21, 2018

^3.1.0

[Intervention] Ignored attempt to cancel a touchmove event with cancelable=false, for example because scrolling is in progress and cannot be interrupted.

img_20180921_082007
img_20180921_082018
img_20180921_082029

@PejmanNik
Copy link

@3.1.0 same error here!

@jlascoleassi
Copy link
Contributor Author

jlascoleassi commented Sep 24, 2018 via email

@9jaGuy
Copy link

9jaGuy commented Sep 24, 2018

I can still see this in 3.1.1

@9jaGuy
Copy link

9jaGuy commented Sep 27, 2018

should I create another bug for this?

@oliviertassinari
Copy link
Member

@9jaboy if you can consistently reproduce the issue on different environment, yes please.

@SerSerch
Copy link

SerSerch commented Nov 5, 2018

@oliviertassinari
3.4.0
problem in react - event.preventDefault()
see the solution in the comments
https://medium.com/@ericclemmons/react-event-preventdefault-78c28c950e46

quickly pull to the right
https://yadi.sk/i/n9jjrC8Z6WSjNw

@shierro
Copy link

shierro commented Nov 8, 2018

Hi @oliviertassinari ,

I also encounter this error, and drawer is semi-open until touch/drag is released

screen shot 2018-11-08 at 9 25 18 pm

On my local machine, versions are:

"@material-ui/core": "^3.4.0"
"react": "^16.6.1"

on prod (http://territorymanager.tools)

"@material-ui/core": "^3.3.1"
"react": "^16.4.2"

Here is how it's used in prod
https://github.com/shierro/tm-app/blob/master/app/components/LeftDrawer/index.js#L33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: drawer This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

No branches or pull requests

6 participants