[SwipeableDrawer] Passive events cancelable = true
@mnajdova is already working on this.
Since Jul 5, 2023.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Steps to reproduce 🕹
Repository with minimal code as an example: https://github.com/meelist/mui-swipeable-drawer-bug
Steps:
- npm i
- npm start
- try to swipe the drawer open
- observe errors in console
Current behavior 😯
Touch events should be cancelable since there is a passive event listener when the drawer is closed. However if there is an overlapping (even underneath) event listener which is not passive, then all touch events become cancelable.
Expected behavior 🤔
Additional check should be added when calling preventDefault in the SwipeableDrawer to check if the listener is passive or not.
Context 🔦
I have a full screen Google Map and I want to overlay the SwipeableDrawer on top of it. Both of these elements have touch event listeners it seems, but Google Map has an active event listener where as the drawer has a passive one when the drawer is closed. This causes a flood of error messages when swiping open the drawer since all events have become cancelable due to this overlap, but the drawer listener was configured as passive. No issues when closing the drawer because the listener isn't passive then. I have reproduced the same issue by just creating a full screen div with a non-passive touch listener.
I think perhaps this issue could be resolved if there was an additional check to see if the listener was set as passive or not when trying to call preventDefault.
Here is where the passive behaviour was changed: https://github.com/mui/material-ui/issues/22493
Your environment 🌎
npx @mui/envinfo
Don't forget to mention which browser you used.
Output from `npx @mui/envinfo` goes here.
System:
OS: macOS 13.4
Binaries:
Node: 20.2.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.6.6 - /opt/homebrew/bin/npm
Browsers:
Chrome: 114.0.5735.198
Edge: Not Found
Safari: 16.5
npmPackages:
@emotion/react: ^11.11.1 => 11.11.1
@emotion/styled: ^11.11.0 => 11.11.0
@mui/base: 5.0.0-beta.6
@mui/core-downloads-tracker: 5.13.7
@mui/material: ^5.13.7 => 5.13.7
@mui/private-theming: 5.13.7
@mui/styled-engine: 5.13.2
@mui/system: 5.13.7
@mui/types: 7.2.4
@mui/utils: 5.13.7
@types/react: ^18.2.14 => 18.2.14
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
typescript: ^4.9.5 => 4.9.5
Browser: Chrome Version 114.0.5735.198 (Official Build) (arm64)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.