From 4019af5936663a89a0a509f746dc0dcc793901e5 Mon Sep 17 00:00:00 2001 From: Sinai Date: Tue, 11 May 2021 02:38:39 +1000 Subject: [PATCH] Hide TypeCompleter on suggestion chosen --- src/UI/Widgets/AutoComplete/TypeCompleter.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/UI/Widgets/AutoComplete/TypeCompleter.cs b/src/UI/Widgets/AutoComplete/TypeCompleter.cs index c54c18a..54c3785 100644 --- a/src/UI/Widgets/AutoComplete/TypeCompleter.cs +++ b/src/UI/Widgets/AutoComplete/TypeCompleter.cs @@ -29,6 +29,8 @@ namespace UnityExplorer.UI.Widgets.AutoComplete private HashSet allowedTypes; + private string chosenSuggestion; + public TypeCompleter(Type baseType, InputFieldRef inputField) { BaseType = baseType; @@ -52,14 +54,14 @@ namespace UnityExplorer.UI.Widgets.AutoComplete suggestions.Clear(); AutoCompleter.Instance.SetSuggestions(suggestions); + chosenSuggestion = suggestion.UnderlyingValue; } private void OnInputFieldChanged(string value) { - value = value ?? ""; - - if (string.IsNullOrEmpty(value)) + if (string.IsNullOrEmpty(value) || value == chosenSuggestion) { + chosenSuggestion = null; AutoCompleter.Instance.ReleaseOwnership(this); } else