Skip to content

Commit d84f46d

Browse files
fix: check isSimpleReporter to be sure of full block field (#206)
isFullBlockField be true in scenarios where it is not the only field and so needs visiting. This happens at least for MakeCode if block dummy input clickable image fields (add remove icons).
1 parent 4a7da79 commit d84f46d

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/line_cursor.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,14 @@ export class LineCursor extends Marker {
245245
return true;
246246
case ASTNode.types.INPUT:
247247
return !(location as Blockly.Connection).isConnected();
248-
case ASTNode.types.FIELD:
249-
// @ts-expect-error isFullBlockField is a protected method.
250-
return !(location as Blockly.Field).isFullBlockField();
248+
case ASTNode.types.FIELD: {
249+
const field = node.getLocation() as Blockly.Field;
250+
return !(
251+
field.getSourceBlock()?.isSimpleReporter() &&
252+
// @ts-expect-error isFullBlockField is a protected method.
253+
field.isFullBlockField()
254+
);
255+
}
251256
default:
252257
return false;
253258
}

src/navigation.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,12 +1456,14 @@ function fakeEventForNode(node: Blockly.ASTNode): PointerEvent {
14561456
* @returns True if we showed the editor, false otherwise.
14571457
*/
14581458
function tryShowFullBlockFieldEditor(block: Blockly.Block): boolean {
1459-
for (const input of block.inputList) {
1460-
for (const field of input.fieldRow) {
1461-
// @ts-expect-error isFullBlockField is a protected method.
1462-
if (field.isClickable() && field.isFullBlockField()) {
1463-
field.showEditor();
1464-
return true;
1459+
if (block.isSimpleReporter()) {
1460+
for (const input of block.inputList) {
1461+
for (const field of input.fieldRow) {
1462+
// @ts-expect-error isFullBlockField is a protected method.
1463+
if (field.isClickable() && field.isFullBlockField()) {
1464+
field.showEditor();
1465+
return true;
1466+
}
14651467
}
14661468
}
14671469
}

0 commit comments

Comments
 (0)