DYN-5921: Clear code block edit flag on unload and focus loss - #17311
DYN-5921: Clear code block edit flag on unload and focus loss#17311Chloepeg wants to merge 1 commit into
Conversation
Reset IsCodeBlockEditorActive when the node view unloads or keyboard focus leaves the editor so graph shortcuts are not stuck disabled after node removal, workspace close, or cancelling a modal dialog (e.g. File - New).
There was a problem hiding this comment.
See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-5921
|
There was a problem hiding this comment.
Pull request overview
This PR addresses a UI-state edge case in DynamoCoreWpf where graph navigation shortcuts could remain disabled after leaving Code Block editing in non-standard ways (e.g., node view unload, modal dialogs, or focus transitions). It makes the IsCodeBlockEditorActive flag more robustly reset so shortcut gating returns to normal.
Changes:
- Clears the code block edit/shortcut suppression flag when the hosting
NodeViewunloads (e.g., node deletion / workspace close). - Clears the flag when keyboard focus leaves the editor (covers cases where
TextArea.LostFocusdoes not commit). - Ensures the flag is re-applied on focus re-entry even if the editor state machine is already in
Editing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/DynamoCoreWpf/Views/CodeBlocks/CodeBlockEditor.cs | Adds unload + keyboard-focus-within handling to reliably clear/reset the shortcut suppression flag. |
| src/DynamoCoreWpf/PublicAPI.Unshipped.txt | Registers the new WPF override in the Public API unshipped surface. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| base.OnIsKeyboardFocusWithinChanged(e); | ||
|
|
||
| if (!IsKeyboardFocusWithin) | ||
| { | ||
| nodeViewModel.DynamoViewModel.IsCodeBlockEditorActive = false; | ||
| } |
jasonstratton
left a comment
There was a problem hiding this comment.
Validate the one comment and we're good to go. Just let me know. Thanks.
| /// </summary> | ||
| private void OnNodeViewUnloaded(object sender, System.Windows.RoutedEventArgs e) | ||
| { | ||
| nodeViewModel.DynamoViewModel.IsCodeBlockEditorActive = false; |
There was a problem hiding this comment.
IsCodeBlockEditorActive is a global var. It is possible to have two CodeBlockEditors open at once (?). If so, there might be a need to check for which one is active before clearing this flag.
This does seem like it may have been by design in the first place, but it is worth checking out to see if there would be any issues and maybe build a test case around it to validate.



This PR is a follow up on #17306 and addresses DYN-5921.
Disabling graph shortcuts while editing a Code Block worked, but the edit flag could stay on if the Code Block went away or lost keyboard focus without a normal save-and-leave. Shortcuts like pan, zoom, and fit view then stayed off until another edit cleared the flag.
This follow-up clears the edit flag on unload to be safe, and fixes a specific case where opening and closing a dialog left graph shortcuts disabled until the canvas was clicked.
Changes:
Declarations
Check these if you believe they are true
Release Notes
Follow-up for the stuck shortcut flag. Clearing it when the node is unloaded, and fixed graph navigation shortcuts sometimes staying disabled after opening and closing a dialog while editing a Code Block.
Reviewers
@zeusongit
@DynamoDS/eidos
FYIs
@dnenov
@johnpierson
@jnealb
@jasonstratton