Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Add an option to keep the menu open after selecting #262

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Blazored.Typeahead/BlazoredTypeahead.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public partial class BlazoredTypeahead<TItem, TValue> : ComponentBase, IDisposab

[Parameter] public bool StopPropagation { get; set; } = false;
[Parameter] public bool PreventDefault { get; set; } = false;
/// <summary>The option to keep the menu open after selecting</summary>
[Parameter] public bool CloseOnSelect { get; set; } = true;

private bool IsSearching { get; set; } = false;
private bool IsShowingSuggestions { get; set; } = false;
Expand Down Expand Up @@ -132,10 +134,10 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
}
}

private void Initialize()
private void Initialize(bool isShowingSuggestions = false)
{
SearchText = "";
IsShowingSuggestions = false;
IsShowingSuggestions = isShowingSuggestions;
IsShowingMask = Value != null;
}

Expand Down Expand Up @@ -424,7 +426,7 @@ private async Task SelectResult(TItem item)

_editContext?.NotifyFieldChanged(_fieldIdentifier);

Initialize();
Initialize(isShowingSuggestions: !CloseOnSelect);
}

private async Task SelectNotFoundPlaceholder()
Expand Down