From 141c242d274ae16471597ee39c65b9c366eba213 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Fri, 18 Jul 2025 13:37:22 -0700 Subject: [PATCH] fix: fix ephemeral focus handling for `FieldAngle` and `FieldNote` --- src/fields/field_note.ts | 2 +- src/fields/scratch_field_angle.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/fields/field_note.ts b/src/fields/field_note.ts index e9539cf55e..67fbfbcdd8 100644 --- a/src/fields/field_note.ts +++ b/src/fields/field_note.ts @@ -286,7 +286,7 @@ export class FieldNote extends Blockly.FieldTextInput { * Show a field with piano keys. */ showEditor_(event: PointerEvent, quietInput = false) { - super.showEditor_(event, quietInput); + super.showEditor_(event, quietInput, false); // Build the SVG DOM. const div = Blockly.DropDownDiv.getContentDiv(); diff --git a/src/fields/scratch_field_angle.ts b/src/fields/scratch_field_angle.ts index 9a058e242d..4b203e9692 100644 --- a/src/fields/scratch_field_angle.ts +++ b/src/fields/scratch_field_angle.ts @@ -157,7 +157,15 @@ class ScratchFieldAngle extends Blockly.FieldNumber { * Show the inline free-text editor on top of the text. */ showEditor_(event: PointerEvent) { - super.showEditor_(event); + // Mobile browsers have issues with in-line textareas (focus & keyboards). + // Also, don't let the parent take ephemeral focus since the drop-down div + // below will handle it, instead. + const noFocus = + Blockly.utils.userAgent.MOBILE || + Blockly.utils.userAgent.ANDROID || + Blockly.utils.userAgent.IPAD; + super.showEditor_(event, noFocus, false); + // If there is an existing drop-down someone else owns, hide it immediately and clear it. Blockly.DropDownDiv.hideWithoutAnimation(); Blockly.DropDownDiv.clearContent();