Skip to content

DYN-9034: Fix context menu for node customizations#16294

Merged
zeusongit merged 4 commits into
DynamoDS:masterfrom
zeusongit:DYN-9034
Jun 17, 2025
Merged

DYN-9034: Fix context menu for node customizations#16294
zeusongit merged 4 commits into
DynamoDS:masterfrom
zeusongit:DYN-9034

Conversation

@zeusongit

Copy link
Copy Markdown
Contributor

Purpose

Fix context menu for node customizations

Declarations

Check these if you believe they are true

  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB
  • This PR introduces new feature code involve network connecting and is tested with no-network mode.

Release Notes

Fix context menu for node customizations

Reviewers

(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)

(FILL ME IN, optional) Any additional notes to reviewers or testers.

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

@zeusongit zeusongit requested review from a team, Copilot and saintentropy June 11, 2025 20:12

@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-9034

This comment was marked as outdated.

Comment thread src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs Outdated
Comment thread src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs Outdated

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 DYN-9034 by fixing the context menu behavior for node customizations. Key changes include updating the stashing mechanism for menu items to use MainContextMenu instead of grid.ContextMenu and updating the DisplayNodeContextMenu method to properly clear and configure the active context menu.

Comments suppressed due to low confidence (1)

src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs:2369

  • [nitpick] It would be beneficial to add a clarifying comment explaining the reasoning behind clearing MainContextMenu.Items and then assigning nodeContextMenu to MainContextMenu, to improve code clarity.
MainContextMenu.Items.Clear();

Comment thread src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs

@aparajit-pratap aparajit-pratap 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.

LGTM but I'm still confused about nodeContextMenu and MainContextMenu. Are these two different things? If not, why do we need two separate properties/fields to refer to the same thing?

@zeusongit

Copy link
Copy Markdown
Contributor Author

LGTM but I'm still confused about nodeContextMenu and MainContextMenu. Are these two different things? If not, why do we need two separate properties/fields to refer to the same thing?

I had the same question initially, but here’s what I gathered from reviewing the implementation:

I’ve replaced most usages of nodeContextMenu with MainContextMenu, and I think there are two main reasons why both exist:
Avoiding binding errors: When re-adding stashed CustomizationMenuItems to the context menu, using nodeContextMenu helps prevent errors about items already being attached. This seems to be a safeguard against reattachment issues.
Performance and encapsulation: nodeContextMenu is a private static variable where we apply the menu style during initialization. Keeping it separate might help with performance or encapsulation, especially if the style setup is meant to be reused.

Comment thread src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs
@aparajit-pratap

Copy link
Copy Markdown
Contributor

Too many context menus hanging around. Perhaps they could be named appropriately to denote which is which and what purpose they serve?

@zeusongit zeusongit merged commit 8e31b82 into DynamoDS:master Jun 17, 2025
15 checks passed
@zeusongit

Copy link
Copy Markdown
Contributor Author

I added some comments to make it clear,
nodeContextMenu is static and used to handle context menu style,
MainContextMenu and grid.ContextMenu are same, but we have to define MainContextMenu separately as it is used publicly in other classes and tests.

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.

4 participants