Skip to content

[stable13.0] Make custom field init() idempotent to fix stuck touch drags #11496

Merged
jwunderl merged 1 commit into
stable13.0from
dev/jwunderl/also-port-touch-drag
Jul 22, 2026
Merged

[stable13.0] Make custom field init() idempotent to fix stuck touch drags #11496
jwunderl merged 1 commit into
stable13.0from
dev/jwunderl/also-port-touch-drag

Conversation

@jwunderl

Copy link
Copy Markdown
Member

port #11491 for microbit stable, have another bug fix for offline app to port / that fix looked good to me to port over as well?

pxt's renderer re-runs field.init() on every render (the input.init()
sweep in RenderInfo.measure, added in #9865 to replace the fork-era
re-runnable BlockSvg.initSvg). Blockly.Field.init() is idempotent, but
FieldBase and FieldCustomMelody ran onInit() unconditionally, rebuilding
the field's DOM on every render.

On touch, the pointerdown target implicitly captures the pointer, so
destroying that element mid-drag breaks event delivery. Dragging a
melody_editor shadow by its preview triggers exactly this: duplicate-
on-drag forces a render at drag start, updateFieldLabel() removes the
captured element, and in an iframe embed Chrome then routes the rest of
the touch's events (including pointerup) to the top-level document. The
gesture never ends, Blockly's touchIdentifier_ stays pinned to the dead
pointer, and every subsequent touch moves the block with no way to drop
it.

Top-level documents seem to recover from this so we can only reproduce
issues in an iframe (e.g. with controller.html).

Guard init() so onInit() runs once per field, matching the
Blockly.Field.init behavior.

Fixes microsoft/pxt-microbit#7045
@jwunderl
jwunderl requested a review from riknoll July 22, 2026 18:05

@aznhassan aznhassan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@jwunderl
jwunderl merged commit 94d183a into stable13.0 Jul 22, 2026
17 checks passed
@jwunderl
jwunderl deleted the dev/jwunderl/also-port-touch-drag branch July 22, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants