From b0edea0209679d382f6ac180a62957efc2ab0a97 Mon Sep 17 00:00:00 2001 From: Kirsty McNaught Date: Thu, 1 Jan 2026 10:49:34 +0000 Subject: [PATCH] Fix field editor focus loss in embedded browsers When MakeCode is embedded in assistive technology apps like Grid 3, page navigation within the AT app causes visibilitychange events that were triggering runSimulator() which calls beforeCompile(), closing any open field editors and causing users to lose their current state or in-progress edits. For example, when you pull up a full QWERTY keyboard to type into a text field, you need to change the 'page' in Grid 3, which calls visibilitychange. Previously this resulted in losing your 'in-edit' status and makes navigation a lot harder. If you need a multi-page QWERTY keyboard (with larger targets and fewer letters per page) then it becomes almost impossible to type into the text field since you keep losing edit focus (and then accidentally triggering single character shortcuts!) With this change, we use `background: true` when resuming the simulator after a visibility change, which prevents the call to beforeCompile() and keeps our 'in-edit' state. --- webapp/src/app.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webapp/src/app.tsx b/webapp/src/app.tsx index 719ebb6ad7a8..87e1aa1578a6 100644 --- a/webapp/src/app.tsx +++ b/webapp/src/app.tsx @@ -489,7 +489,11 @@ export class ProjectView } else if (this.state.resumeOnVisibility) { this.setState({ resumeOnVisibility: false }); // We did a save when the page was hidden, no need to save again. - this.runSimulator(); + // Use background: true to avoid calling beforeCompile, which would + // close any open field editors (e.g., text input on a block). + // This is important for embedded browsers like Grid 3 where page + // changes cause brief visibility changes but the user is still editing. + this.runSimulator({ background: true }); cmds.maybeReconnectAsync(false, true); } else if (!this.state.home) { cmds.maybeReconnectAsync(false, true);