Skip to content

Commit

Permalink
Autocomplete | Fix FreeTypingNotFoundTemplate not showing
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Moreira committed Oct 5, 2023
1 parent 584be17 commit bd3c642
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Source/Extensions/Blazorise.Components/Autocomplete.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@typeparam TItem
@typeparam TValue

<Dropdown ElementId="@ElementId" Class="@DropdownClassNames" Style="@CssStyle" Attributes="@Attributes" Visible="@(DropdownVisible || NotFoundVisible)" PositionStrategy="@PositionStrategy" DropdownMenuTargetId="@InputElementId" Disabled="@Disabled">
<Dropdown ElementId="@ElementId" Class="@DropdownClassNames" Style="@CssStyle" Attributes="@Attributes" Visible="@(DropdownVisible || NotFoundVisible || FreeTypingNotFoundVisible)" PositionStrategy="@PositionStrategy" DropdownMenuTargetId="@InputElementId" Disabled="@Disabled">
<Validation Validator="@(Validator ?? ValidationRule.None)" AsyncValidator="@AsyncValidator">

@if ( IsMultiple && !SelectedTexts.IsNullOrEmpty() )
Expand Down
30 changes: 30 additions & 0 deletions Tests/BasicTestApp.Client/Autocomplete_5038Component.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Autocomplete TItem="string"
TValue="string"
Data="@colors"
Placeholder="Search..."
Filter="AutocompleteFilter.StartsWith"
FreeTyping
TextField="@(( item ) => item)"
ValueField="@(( item ) => item)">
<FreeTypingNotFoundTemplate>
Add "@context"
</FreeTypingNotFoundTemplate>
</Autocomplete>

@code {
private List<string> colors = new List<string>
{
"Red",
"Orange",
"Yellow",
"Bright Green",
"Dark Green",
"Sky Blue",
"Blue",
"Purple",
"Hot Pink",
"Black",
"White",
"Gray"
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace Blazorise.E2E.Tests.Tests.Extensions.Autocomplete;

[Parallelizable( ParallelScope.Self )]
[TestFixture]
public class Autocomplete_5038_Tests : BlazorisePageTest
{

[SetUp]
public async Task Init()
{
await SelectTestComponent<Autocomplete_5038Component>();
}

/// <summary>
/// When a value is already set, setting a different value programmatically and then revisiting should have updated the Current Search Value and options shown.
/// </summary>
/// <returns></returns>
[Test]
public async Task Test()
{
var sut = Page.Locator( ".b-is-autocomplete input[type=search]" );
var dropdownMenu = Page.Locator( ".dropdown-menu.show" );

await sut.ClickAsync();
await sut.FillAsync( "My Color" );
await sut.PressAsync( "Enter" );
await Expect( sut ).ToHaveValueAsync( "My Color" );

await dropdownMenu.WaitForAsync();
var option = ( await dropdownMenu.Locator( ".dropdown-item" ).AllAsync() ).Single();

await Expect( option ).ToHaveTextAsync( @"Add ""My Color""" );
}
}

0 comments on commit bd3c642

Please sign in to comment.