protected override string OnAddingTag(string tagText) { var exactMatch = AutoCompletionSuggestions.FirstOrDefault(suggestion => suggestion.Text == tagText); if (exactMatch == null) { var alternativeMatch = AutoCompletionSuggestions .FirstOrDefault(suggestion => suggestion.Text.StartsWith(tagText))?.Text; tagText = alternativeMatch ?? tagText; } return(tagText); }
private void UpdateAutoCompleteSuggestions(string searchTerm) { using (AutoCompletionSuggestions.EnterMassUpdate()) { AutoCompletionSuggestions.Clear(); searchTerm = searchTerm?.Trim(); if (string.IsNullOrEmpty(searchTerm)) { return; } var newSuggestions = _tagIndex .GetRecommendations(Tags.Select(t => t.Text), searchTerm) .Select(result => new SuggestionModel(result.SearchTag, SuggestionChosen)) .Take(10); AutoCompletionSuggestions.AddRange(newSuggestions); } }