mui / mui/material-ui

Draggable Dialog w/Autocomplete disconnects when dragged on touch interfaces

Open
#26,494 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component: Popper scope: autocomplete scope: popup type: bug
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Using the draggable dialog template described here and including in its contents the combo box described here, if we attempt to drag the dialog while the combo box is open on touch devices (iPad 6 & 7, iPhone 6, Safari & Chrome tested), the combo box popper disconnects from the dialog and remains in its original position. Additionally, the text cursor gets stuck in position until the next time the dialog is dragged or the input is selected. This:

disconnected popper and floating text cursor

is the result, noting the floating text cursor circled in red. Note that this second aberrant behavior exhibits with any TextField, not just one used inside an AutoComplete.

Expected Behavior 🤔

One of two things should happen:

  1. The input should lose focus, causing the text cursor and popper to disappear. Incidentally, this is the behavior on desktop. I would expect that the core issue is still present on desktop, but it is rendered moot by automatically blurring when dragging.
  2. The text cursor and popper should move together with the dialog when dragged.

Steps to Reproduce 🕹

https://codesandbox.io/s/weathered-frog-me457?file=/src/App.js

Steps:

  1. On a touch device, focus the input, causing the popper to appear.
  2. Drag and observe that the popper and text cursor do not move with the rest of the dialog.

Note that the floating popper behavior can be observed using the Chrome devtools device toolbar (try e.g. iPad). The floating text cursor behavior is only present on the actual devices.

Context 🔦

There are many scenarios where a draggable dialog including an autocomplete component would be useful. In my specific case, I am saving previously entered input in local storage and displaying it (freeSolo) sorted and grouped by recency. Draggability can improve suggestion visibility on some screens.

Your Environment 🌎

`npx @material-ui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @material-ui/envinfo` goes here.

My development environment is not actually relevant, because, as mentioned above, this issue only exhibits on touch devices (iPad 6 & 7, iPhone 6, Safari & Chrome tested), but including for completeness:

System:
OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
Binaries:
Node: 14.17.0 - /usr/bin/node
Yarn: 1.22.5 - /usr/bin/yarn
npm: 6.14.13 - /usr/bin/npm
Browsers:
Chrome: 90.0.4430.212
Firefox: 88.0.1

Additional comments

I originally posted this as a stack overflow question, and I was able to find a "solution" (emulate the desktop behavior of automatically blurring) as described here. See also this sandbox. At the very least, I would think a version of my patch should appear somewhere in your docs, but as it hides rather than addresses the issue, it's probably better to do something more substantial.

I'm pretty sure that the fact that the generated Popper is a child of body and not the draggable div is the problem, which is why I think this is a material-ui issue and not a react-draggable issue. However, I don't have any theories at the moment about why the text cursor only catches up when the dialog is grabbed again, so that may well be react-draggable's fault and not relevant to this bug. Please advise if you would like me to file that portion of the issue with them instead.

EDIT: It occurred to me that I could do a simple experiment to see if the floating cursor issue exhibits with just a vanilla input (no material-ui). This sandbox (when viewed on a touch device) indicates that it does not, so I think both parts of this belong here as material-ui issues.

EDIT 2: It turns out that the Chrome devtools device toolbar is sufficient to observe the floating popper (but not the floating text cursor). I have edited the "Steps to Reproduce" section to reflect this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the draggable dialog and Autocomplete examples linked in the issue, then reproduce the behavior in the provided CodeSandbox using touch-device emulation and a real touch device. Compare the open Popper and text cursor while dragging. Done means the input loses focus or both the cursor and Popper move with the dialog.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.