Skip to content

DYN-5921: Clear code block edit flag on unload and focus loss - #17311

Open
Chloepeg wants to merge 1 commit into
DynamoDS:masterfrom
Chloepeg:DYN-5921-Shortcut-In-Code-Blocks-update
Open

DYN-5921: Clear code block edit flag on unload and focus loss#17311
Chloepeg wants to merge 1 commit into
DynamoDS:masterfrom
Chloepeg:DYN-5921-Shortcut-In-Code-Blocks-update

Conversation

@Chloepeg

Copy link
Copy Markdown
Contributor

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:

  • Turn the flag off when the node view is unloaded, for example when the node is deleted or the workspace closes
  • Turn the flag off when keyboard focus leaves the editor, e.g. : File, New, Cancel
  • Turn the flag back on when the user clicks into the Code Block again
  • Register the new override in PublicAPI.Unshipped.txt

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

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).
@github-actions github-actions Bot changed the title Clear code block edit flag on unload and focus loss DYN-5921: Clear code block edit flag on unload and focus loss Aug 25, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-5921

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 NodeView unloads (e.g., node deletion / workspace close).
  • Clears the flag when keyboard focus leaves the editor (covers cases where TextArea.LostFocus does 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.

Comment on lines +142 to +147
base.OnIsKeyboardFocusWithinChanged(e);

if (!IsKeyboardFocusWithin)
{
nodeViewModel.DynamoViewModel.IsCodeBlockEditorActive = false;
}

@jasonstratton jasonstratton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants