diff --git a/src/DynamoCore/DynamoCore.csproj b/src/DynamoCore/DynamoCore.csproj
index c7d68ccebc2..818e21338a0 100644
--- a/src/DynamoCore/DynamoCore.csproj
+++ b/src/DynamoCore/DynamoCore.csproj
@@ -89,10 +89,10 @@
-
+
- True
True
+ True
Resources.resx
diff --git a/src/DynamoCoreWpf/Controls/NodeAutoCompleteSearchControl.xaml.cs b/src/DynamoCoreWpf/Controls/NodeAutoCompleteSearchControl.xaml.cs
index a1ba77a8a4c..16fbbdc0de4 100644
--- a/src/DynamoCoreWpf/Controls/NodeAutoCompleteSearchControl.xaml.cs
+++ b/src/DynamoCoreWpf/Controls/NodeAutoCompleteSearchControl.xaml.cs
@@ -8,6 +8,7 @@
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Threading;
+using Dynamo.Graph.Nodes;
using Dynamo.Graph.Nodes.ZeroTouch;
using Dynamo.Graph.Workspaces;
using Dynamo.Logging;
@@ -213,6 +214,19 @@ private void OnNodeAutoCompleteSearchControlVisibilityChanged(object sender, Dep
SearchTextBox.Focus();
ViewModel.PopulateAutoCompleteCandidates();
}), DispatcherPriority.Loaded);
+
+ ViewModel.ParentNodeRemoved += OnParentNodeRemoved;
+ }
+
+ //Removes nodeautocomplete menu when the associated parent node is removed.
+ private void OnParentNodeRemoved(NodeModel node)
+ {
+ NodeModel parent_node = ViewModel.PortViewModel?.PortModel.Owner;
+ if (node == parent_node)
+ {
+ OnRequestShowNodeAutoCompleteSearch(ShowHideFlags.Hide);
+ ViewModel.ParentNodeRemoved -= OnParentNodeRemoved;
+ }
}
private void OnMembersListBoxUpdated(object sender, DataTransferEventArgs e)
@@ -351,12 +365,13 @@ private void OnMoreInfoClicked(object sender, RoutedEventArgs e)
internal void CloseAutocompletionWindow(object sender, RoutedEventArgs e)
{
- OnRequestShowNodeAutoCompleteSearch(ShowHideFlags.Hide);
+ CloseAutoCompletion();
}
internal void CloseAutoCompletion()
{
OnRequestShowNodeAutoCompleteSearch(ShowHideFlags.Hide);
+ ViewModel?.OnNodeAutoCompleteWindowClosed();
}
///
diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
index 1782422084c..97c458f9fe9 100644
--- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
+++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
@@ -22,7 +22,6 @@
using Dynamo.Graph.Nodes;
using Dynamo.Graph.Workspaces;
using Dynamo.Interfaces;
-using Dynamo.Logging;
using Dynamo.Models;
using Dynamo.PackageManager;
using Dynamo.PackageManager.UI;
@@ -2794,7 +2793,6 @@ internal bool CanDelete(object parameters)
return DynamoSelection.Instance.Selection.Count > 0;
}
-
public void SaveImage(object parameters)
{
OnRequestSaveImage(this, new ImageSaveEventArgs(parameters.ToString()));
diff --git a/src/DynamoCoreWpf/ViewModels/Search/NodeAutoCompleteSearchViewModel.cs b/src/DynamoCoreWpf/ViewModels/Search/NodeAutoCompleteSearchViewModel.cs
index f2552201f5b..3870188c4ab 100644
--- a/src/DynamoCoreWpf/ViewModels/Search/NodeAutoCompleteSearchViewModel.cs
+++ b/src/DynamoCoreWpf/ViewModels/Search/NodeAutoCompleteSearchViewModel.cs
@@ -151,6 +151,8 @@ public bool DisplayLowConfidence
}
}
+ internal event Action ParentNodeRemoved;
+
///
/// Constructor
///
@@ -530,6 +532,7 @@ internal void PopulateAutoCompleteCandidates()
{
if (PortViewModel == null) return;
+ dynamoViewModel.CurrentSpaceViewModel.Model.NodeRemoved += NodeViewModel_Removed;
ResetAutoCompleteSearchViewState();
if (IsDisplayingMLRecommendation)
@@ -595,6 +598,16 @@ internal void PopulateDefaultAutoCompleteCandidates()
}
}
+ internal void OnNodeAutoCompleteWindowClosed()
+ {
+ dynamoViewModel.CurrentSpaceViewModel.Model.NodeRemoved -= NodeViewModel_Removed;
+ }
+
+ internal void NodeViewModel_Removed(NodeModel node)
+ {
+ ParentNodeRemoved?.Invoke(node);
+ }
+
///
/// Returns a IEnumberable of NodeSearchElementViewModel for respective NodeSearchElements.
///
diff --git a/test/DynamoCoreWpfTests/NodeAutoCompleteSearchTests.cs b/test/DynamoCoreWpfTests/NodeAutoCompleteSearchTests.cs
index b1225c9cf65..a90471daf5e 100644
--- a/test/DynamoCoreWpfTests/NodeAutoCompleteSearchTests.cs
+++ b/test/DynamoCoreWpfTests/NodeAutoCompleteSearchTests.cs
@@ -500,6 +500,37 @@ public void SearchNodeAutocompletionSuggestions()
Assert.AreEqual(5 , searchViewModel.FilteredResults.Count());
}
+ [Test]
+ public void CloseNodeAutocompleteWhenParentNodeDeleted()
+ {
+ Open(@"UI\builtin_inputport_suggestion.dyn");
+
+ // Get the node view for a specific node in the graph
+ NodeView nodeView = NodeViewWithGuid(Guid.Parse("77aad5875f124bf59a4ece6b30813d3b").ToString());
+
+ var inPorts = nodeView.ViewModel.InPorts;
+ Assert.AreEqual(2, inPorts.Count());
+ var port = inPorts[0].PortModel;
+ var type = port.GetInputPortType();
+ Assert.AreEqual("DSCore.Color[]", type);
+
+ var searchViewModel = (ViewModel.CurrentSpaceViewModel.NodeAutoCompleteSearchViewModel as NodeAutoCompleteSearchViewModel);
+ searchViewModel.PortViewModel = inPorts[0];
+ searchViewModel.dynamoViewModel.PreferenceSettings.DefaultNodeAutocompleteSuggestion = NodeAutocompleteSuggestion.ObjectType;
+
+ // Get the matching node elements for the specific node port.
+ searchViewModel.PopulateAutoCompleteCandidates();
+ // Show Node AutoCompleteSearchBar
+ ViewModel.CurrentSpaceViewModel.OnRequestNodeAutoCompleteSearch(ShowHideFlags.Show);
+ //remove the parent node
+ searchViewModel.dynamoViewModel.CurrentSpaceViewModel.Model.RemoveAndDisposeNode(nodeView.ViewModel.NodeModel);
+
+ var currentWs = View.ChildOfType();
+ //confirm if the AutoCompleteSearchBar is closed.
+ Assert.IsFalse(currentWs.NodeAutoCompleteSearchBar.IsOpen);
+
+ }
+
[Test]
public void NodeSuggestions_SkippedSuggestions()
{