material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[SwipeableDrawer] Portal inside shadow DOM mobile touch event ignored

Open Mohanrau opened this issue 3 years ago • 8 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Steps to reproduce 🕹

Link to live example: https://codesandbox.io/s/lingering-water-wr6cqx

Steps:

  1. switch browser to mobile mode and try to swipe from bottom

Current behavior 😯

Mobile touch events ignored if MuiModal use ShadowDom as container.

Expected behavior 🤔

Working on mobile

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo
chrome

  System:
    OS: Linux 5.15 Ubuntu 20.04.5 LTS (Focal Fossa)
  Binaries:
    Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
    Yarn: 1.22.19 - /mnt/c/Program Files (x86)/Yarn/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    @emotion/react: 11.10.6 => 11.10.6 
    @emotion/styled: 11.10.6 => 11.10.6 
    @mui/base:  5.0.0-beta.3 
    @mui/core-downloads-tracker:  5.13.3 
    @mui/icons-material: ^5.11.0 => 5.11.16 
    @mui/lab: ^5.0.0-alpha.120 => 5.0.0-alpha.132 
    @mui/material: ^5.9.1 => 5.13.3 
    @mui/private-theming:  5.13.1 
    @mui/styled-engine:  5.13.2 
    @mui/system:  5.13.2 
    @mui/types:  7.2.4 
    @mui/utils:  5.13.1 
    @types/react: 18.0.28 => 18.0.28 
    react: 18.2.0 => 18.2.0 
    react-dom: 18.2.0 => 18.2.0 
    styled-components: 5.3.6 => 5.3.6 
    typescript: 5.0.4 => 5.0.4 

Mohanrau avatar Jun 19 '23 09:06 Mohanrau

Hi @gzrae , just wanted to know is there any fixes for this issue any time soon, if not i will move to alternative solution.

Mohanrau avatar Jul 10 '23 22:07 Mohanrau

@Mohanrau What is your use case for having the Swipeable Drawer component inside a Shadow DOM?

ZeeshanTamboli avatar Jul 29 '23 14:07 ZeeshanTamboli

Hi @ZeeshanTamboli i have a worpress plugin that has custom react components and i have a custom theme, so to avoid css override, i use shadow dom.

Mohanrau avatar Jul 30 '23 11:07 Mohanrau

@ZeeshanTamboli I think i have the same problem. It seems there is an issue with the onTouchStart event listener. The listener is added to the ownerDocument, which is always the document element. When the handleBodyTouchStart method of the SwipeableDrawer is called by onTouchStart, the nativeEvent.target always points to the shadow dom root element. But in SwipeableDrawer.js:524 the condition expects the nativeEvent.target to be the same as swipeAreaRef.current. The swipeAreaRef.current points to a div inside the shadow dom. That's why the swipe will be ignored. Is there a known workaround or fix?

sebastianbrenner avatar Aug 04 '23 13:08 sebastianbrenner

While shadow DOM isn't commonly used, I've labeled this as a bug since we have documentation for it at https://mui.com/material-ui/guides/shadow-dom/. The fix could be to use getRootNode() for attaching event listeners which will pick the shadow root if present. For reference, you can see the fix done for tree item in https://github.com/mui/material-ui/pull/36225.

ZeeshanTamboli avatar Aug 08 '23 08:08 ZeeshanTamboli

Shadow DOM is a niche use case, but it seems to be a low effort, it would make sense. We also support different windows (popup, iframes) with ownerDocument() which is another niche use case.

oliviertassinari avatar Aug 08 '23 14:08 oliviertassinari

Any update on this? @oliviertassinari My company (huge bank in Australia) is using MUI. Shadow DOM is part of our core architecture so any support MUI has on shadow dom is really appreciated.

Also keen to know if there's any workaround at this point.

VietNguyenQuoc avatar May 07 '25 07:05 VietNguyenQuoc

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.


@Mohanrau Thanks again for creating this issue! If you have a moment, we would love to hear your thoughts on how we handled it with this short feedback form.

github-actions[bot] avatar Nov 14 '26 12:11 github-actions[bot]