Repository navigation
Commit 0c7998e
authored
Make custom field init() idempotent to fix stuck touch drags (microsoft#11491)
pxt's renderer re-runs field.init() on every render (the input.init()
sweep in RenderInfo.measure, added in microsoft#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#70451 parent ad3e0f8 commit 0c7998e
2 files changed
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
0 commit comments