microsoft / microsoft/pxt-microbit

Monaco flyout: fast drag on iPad leaves a stuck ghost block over the editor

Open
#6,928 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ipad monaco P2
Dominant language
TypeScript
Stars
804
Forks
721
Avg merge
2d 9h
Merged PRs (30d)
2

Description

Summary

When quickly dragging a code snippet out of the Monaco toolbox flyout on iPad the drag sometimes neither inserts the snippet nor fails cleanly. The dragged ghost element stays over the editor and breaks subsequent drag attempts.

Spotted when testing https://github.com/microsoft/pxt/pull/11404 as I did a lot of dragging but repros in live.

Steps to reproduce
  1. Open the Monaco (JS/Python) editor on an iPad.
  2. Open a toolbox category flyout.
  3. Quickly drag/flick a snippet toward the editor. My best repro is to tap Input and drag the first block diagonally up and to the right ~1.5cm.

You might need to try a few times. I made a video but for some reason I can't upload it so here's a screenshot of the broken state post-drag:

Image
Cause

The flyout drag uses pointer listeners (see webapp/src/monacoFlyout.tsx). On a fast touch, iOS Safari can claim the gesture as a scroll/pan and fire pointercancel instead of pointerup. The flyout only listens for pointerup, so blockDragEndHandler doesn't run, leaving the #monacoDraggingBlock ghost in the DOM, plus stale insertionSnippet/dragInfo and #root { overflow: hidden }, which corrupts the next drag. This is a touch-only problem so you can't reproduce with the mouse.

Potential fix

Route pointercancel (and touchcancel) to the existing blockDragEndHandler.

A fast flick may still be interpreted as a scroll rather than completing the insertion, but it now fails cleanly without blocking later drags.

Another option is touch-action: none on the block body, but I'm worried that will conflict with flyout scrolling. Haven't tried it though.

I quickly tried the pointercancel option but it's a bit weird when the flyout just closes without anything happening so raising this in case there are better ideas.

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 in webapp/src/monacoFlyout.tsx and trace the pointer listeners, blockDragEndHandler, insertionSnippet, dragInfo, and #monacoDraggingBlock cleanup. Reproduce the fast touch drag on an iPad or equivalent touch environment, then verify that cancellation leaves no ghost block or stale drag state and that later drags still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.