Conversation
Preview only mode hides the editor, and the VCL refuses to focus a control that is not visible. Clicking Bold, Italic, Link or Code then raised EInvalidOperation with 'Cannot focus a disabled or invisible window', and so did every command on the shared format path, clicking an entry in the contents list, and the palette's undo, redo, select all, indent, outdent and delete word. Route every path that returns focus to the editor through a FocusEditor helper carrying the CanFocus guard that the zen mode code already used. The VCL applied that guard in four places out of sixteen. The FMX studio applied it nowhere, so it could raise from leaving zen mode and from closing the command palette as well.
This was referenced Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Independent of #7, #8 and #9. Cut from
mainand touching different lines, so it can merge in any order.The bug
In preview only mode the studio raises:
ApplyViewModehides the editor in preview only mode, and the VCL refuses to focus a control that is not visible.Reachable entry points, all in preview only mode:
ExecuteFormatCommand, so every palette formatting entry and keyboard shortcut, including headings, lists, quote, strikethrough and insert table.The fix
The codebase already had the right idiom. Zen mode, closing the find bar and closing the palette guarded with
if mdEditor.CanFocus then. Those guards were simply missing everywhere else.Every path that returns focus to the editor now goes through one
FocusEditorhelper carrying that guard, so no call site can reintroduce the fault.The VCL had the guard in 4 places out of 16. The FMX studio had it in none of its 17, so it could also raise when leaving zen mode and when closing the command palette.
Testing
This is form and focus behaviour with no pure logic to unit test, so it is verified by driving the app rather than by adding to the DUnitX suite.
Related
While in preview only mode a formatting command still applies at the editor's last caret position, which you cannot see. Mapping a selection made in the preview back to a source range is the proper answer to that, and is being built separately.