-
Notifications
You must be signed in to change notification settings - Fork 654
Hide All context menu in workspace when displaying node context menu #12565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,16 +124,17 @@ void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) | |
private void RemoveViewModelsubscriptions(WorkspaceViewModel ViewModel) | ||
{ | ||
ViewModel.RequestShowInCanvasSearch -= ShowHideInCanvasControl; | ||
ViewModel.RequestHideAllPopup -= HideAllPopUp; | ||
ViewModel.RequestNodeAutoCompleteSearch -= ShowHideNodeAutoCompleteControl; | ||
ViewModel.RequestPortContextMenu -= ShowHidePortContextMenu; | ||
ViewModel.DynamoViewModel.PropertyChanged -= ViewModel_PropertyChanged; | ||
|
||
ViewModel.ZoomChanged -= vm_ZoomChanged; | ||
ViewModel.RequestZoomToViewportCenter -= vm_ZoomAtViewportCenter; | ||
ViewModel.RequestZoomToViewportPoint -= vm_ZoomAtViewportPoint; | ||
ViewModel.RequestZoomToFitView -= vm_ZoomToFitView; | ||
ViewModel.RequestCenterViewOnElement -= CenterViewOnElement; | ||
|
||
ViewModel.RequestAddViewToOuterCanvas -= vm_RequestAddViewToOuterCanvas; | ||
ViewModel.WorkspacePropertyEditRequested -= VmOnWorkspacePropertyEditRequested; | ||
ViewModel.RequestSelectionBoxUpdate -= VmOnRequestSelectionBoxUpdate; | ||
|
@@ -151,6 +152,7 @@ private void RemoveViewModelsubscriptions(WorkspaceViewModel ViewModel) | |
private void AttachViewModelsubscriptions(WorkspaceViewModel ViewModel) | ||
{ | ||
ViewModel.RequestShowInCanvasSearch += ShowHideInCanvasControl; | ||
ViewModel.RequestHideAllPopup += HideAllPopUp; | ||
ViewModel.RequestNodeAutoCompleteSearch += ShowHideNodeAutoCompleteControl; | ||
ViewModel.RequestPortContextMenu += ShowHidePortContextMenu; | ||
ViewModel.DynamoViewModel.PropertyChanged += ViewModel_PropertyChanged; | ||
|
@@ -172,7 +174,7 @@ private void AttachViewModelsubscriptions(WorkspaceViewModel ViewModel) | |
} | ||
|
||
private void ShowHideNodeAutoCompleteControl(ShowHideFlags flag) | ||
{ | ||
{ | ||
ShowHidePopup(flag, NodeAutoCompleteSearchBar); | ||
} | ||
|
||
|
@@ -239,7 +241,7 @@ private void ShowHidePopup(ShowHideFlags flag, Popup popup) | |
// If the dispatcher is not used in this scenario when switching | ||
// from inputPort context menu to Output port context menu, | ||
// the popup will display before the new content is fully rendered | ||
this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() =>{ | ||
this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => { | ||
popup.Child.Visibility = Visibility.Visible; | ||
popup.Child.UpdateLayout(); | ||
popup.IsOpen = displayPopup; | ||
|
@@ -253,15 +255,23 @@ private void ShowHidePopup(ShowHideFlags flag, Popup popup) | |
} | ||
|
||
/// <summary> | ||
/// Hides Context Menu as well as InCanvasControl (Right Click PopUp) | ||
/// Hides all popups in the view, the amount of popup hidden will be different depending on | ||
/// if the hide view command is triggered on node level or workspace level | ||
/// </summary> | ||
public void HidePopUp() | ||
public void HideAllPopUp(object sender) | ||
{ | ||
// First make sure workspace level popups are hidden | ||
if (InCanvasSearchBar.IsOpen || ContextMenuPopup.IsOpen) | ||
{ | ||
ShowHideContextMenu(ShowHideFlags.Hide); | ||
ShowHideInCanvasControl(ShowHideFlags.Hide); | ||
} | ||
// If triggered on node level, make sure node popups are also hidden | ||
if(sender is NodeView && (PortContextMenu.IsOpen || NodeAutoCompleteSearchBar.IsOpen) ) | ||
{ | ||
ShowHidePopup(ShowHideFlags.Hide, PortContextMenu); | ||
ShowHidePopup(ShowHideFlags.Hide, NodeAutoCompleteSearchBar); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if the sender is not the nodeview (if it's the workspace), the node level popups can still be open? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is the intended design from UX originally. e.g. if node autocomplete is triggered, but user clicking on canvas, the node autocomplete dialog should remain open |
||
} | ||
|
||
internal Point GetCenterPoint() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,15 +431,17 @@ public void UpdateModelValue_MissingNode_ThrowsException() | |
CurrentDynamoModel.CurrentWorkspace.RemoveAndDisposeNode(addNode); | ||
|
||
var command = new DynCmd.UpdateModelValueCommand(Guid.Empty, addNode.GUID, "Code", ""); | ||
Assert.Throws<InvalidOperationException>(() => CurrentDynamoModel.ExecuteCommand(command)); | ||
Assert.Throws<InvalidOperationException>(() => CurrentDynamoModel.CurrentWorkspace.UpdateModelValue(command.ModelGuids, | ||
command.Name, command.Value)); | ||
} | ||
|
||
[Test] | ||
[Category("UnitTests")] | ||
public void UpdateModelValue_EmptyList_ThrowsException() | ||
{ | ||
var command = new DynCmd.UpdateModelValueCommand(Guid.Empty, new Guid[] { }, "", ""); | ||
Assert.Throws<ArgumentNullException>(() => CurrentDynamoModel.ExecuteCommand(command)); | ||
Assert.Throws<ArgumentNullException>(() => CurrentDynamoModel.CurrentWorkspace.UpdateModelValue(command.ModelGuids, | ||
command.Name, command.Value)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aparajit-pratap Let me know if you have a strong opinion on this. In my opinion, this should not crash Dynamo but currently, it is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you remind me how these exceptions can be reproduced exactly? Looking at that old PR, I see that these exceptions are thrown when either the nodemodel is not found in the workspace or the list of nodemodels passed is null or empty, but how exactly can these situations be reproduced. |
||
} | ||
|
||
[Test] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know what kinds of exceptions are these and why are they thrown?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is code inside the function
UpdateModelValue
that throw the invalid operation exception, but they are not caught anywhere. In that case, Dynamo will simply crash