-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#791 FocusAsync() not working for indirect input-components
- Loading branch information
Showing
15 changed files
with
280 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
@page "/HxMultiSelect_Issue791_Test" | ||
@using System.Globalization | ||
|
||
<h1>HxMultiSelect</h1> | ||
|
||
|
||
<EditForm Model="@model"> | ||
<HxMultiSelect @ref="_component" | ||
TItem="CultureInfo" | ||
TValue="string" | ||
Label="Cultures" | ||
EmptyText="-- choose here --" | ||
TextSelector="@(item => item.EnglishName)" | ||
ValueSelector="@(item => item.EnglishName)" | ||
Data="@data" | ||
@bind-Value="@model.CultureInfos" | ||
NullDataText="Loading languages..." | ||
InputSize="InputSize.Small" /> | ||
</EditForm> | ||
|
||
<p>Selected values: @String.Join(", ", model.CultureInfos ?? Enumerable.Empty<string>())</p> | ||
|
||
@code | ||
{ | ||
private HxMultiSelect<string, CultureInfo> _component; | ||
private Model model = new Model(); | ||
private List<CultureInfo> data; | ||
|
||
protected override async Task OnParametersSetAsync() | ||
{ | ||
await base.OnParametersSetAsync(); | ||
await Task.Delay(3000); | ||
|
||
data = CultureInfo.GetCultures(CultureTypes.SpecificCultures) | ||
.OrderBy(item => item.EnglishName) | ||
.Take(100) | ||
.OrderByDescending(i => i.ToString()) // sorting test | ||
.ToList(); | ||
} | ||
|
||
protected override async Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
await _component.FocusAsync(); | ||
} | ||
|
||
private class Model | ||
{ | ||
public List<string> CultureInfos { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
@page "/HxSearchBox_Issue791_Test" | ||
|
||
<HxSearchBox @ref="_component" | ||
DataProvider="ProvideSearchResults" | ||
Label="Search" | ||
ItemTitleSelector="(i) => i.Title" | ||
ItemSubtitleSelector="(i) => i.Subtitle" | ||
ItemIconSelector="(i) => i.Icon" | ||
TItem="SearchBoxItem"> | ||
<DefaultContentTemplate> | ||
<div class="small py-2 px-3 text-muted">Search for Mouse, Table or Door...</div> | ||
</DefaultContentTemplate> | ||
</HxSearchBox> | ||
|
||
@code { | ||
private HxSearchBox<SearchBoxItem> _component; | ||
|
||
List<SearchBoxItem> Data { get; set; } = new() | ||
{ | ||
new() { Title = "Table", Subtitle = "$5000", Icon = BootstrapIcon.Table }, | ||
new() { Title = "Mouse", Subtitle = "$40", Icon = BootstrapIcon.Mouse }, | ||
new() { Title = "Door", Subtitle = "$100", Icon = BootstrapIcon.DoorClosed }, | ||
new() { Title = "Table", Subtitle = "$5000", Icon = BootstrapIcon.Table }, | ||
new() { Title = "Mouse", Subtitle = "$40", Icon = BootstrapIcon.Mouse }, | ||
new() { Title = "Door", Subtitle = "$100", Icon = BootstrapIcon.DoorClosed }, | ||
new() { Title = "Table", Subtitle = "$5000", Icon = BootstrapIcon.Table }, | ||
new() { Title = "Mouse", Subtitle = "$40", Icon = BootstrapIcon.Mouse }, | ||
new() { Title = "Door", Subtitle = "$100", Icon = BootstrapIcon.DoorClosed }, | ||
new() { Title = "Table", Subtitle = "$5000", Icon = BootstrapIcon.Table }, | ||
new() { Title = "Mouse", Subtitle = "$40", Icon = BootstrapIcon.Mouse }, | ||
new() { Title = "Door", Subtitle = "$100", Icon = BootstrapIcon.DoorClosed }, | ||
new() { Title = "Table", Subtitle = "$5000", Icon = BootstrapIcon.Table }, | ||
new() { Title = "Mouse", Subtitle = "$40", Icon = BootstrapIcon.Mouse }, | ||
new() { Title = "Door", Subtitle = "$100", Icon = BootstrapIcon.DoorClosed }, | ||
new() { Title = "Table", Subtitle = "$5000", Icon = BootstrapIcon.Table }, | ||
new() { Title = "Mouse", Subtitle = "$40", Icon = BootstrapIcon.Mouse }, | ||
new() { Title = "Door", Subtitle = "$100", Icon = BootstrapIcon.DoorClosed }, | ||
new() { Title = "Table", Subtitle = "$5000", Icon = BootstrapIcon.Table }, | ||
new() { Title = "Mouse", Subtitle = "$40", Icon = BootstrapIcon.Mouse }, | ||
new() { Title = "Door", Subtitle = "$100", Icon = BootstrapIcon.DoorClosed }, | ||
new() { Title = "Table", Subtitle = "$5000", Icon = BootstrapIcon.Table }, | ||
new() { Title = "Mouse", Subtitle = "$40", Icon = BootstrapIcon.Mouse }, | ||
new() { Title = "Door", Subtitle = "$100", Icon = BootstrapIcon.DoorClosed }, | ||
new() { Title = "Table", Subtitle = "$5000", Icon = BootstrapIcon.Table }, | ||
new() { Title = "Mouse", Subtitle = "$40", Icon = BootstrapIcon.Mouse }, | ||
new() { Title = "Door", Subtitle = "$100", Icon = BootstrapIcon.DoorClosed }, | ||
new() { Title = "Table", Subtitle = "$5000", Icon = BootstrapIcon.Table }, | ||
new() { Title = "Mouse", Subtitle = "$40", Icon = BootstrapIcon.Mouse }, | ||
new() { Title = "Door", Subtitle = "$100", Icon = BootstrapIcon.DoorClosed } | ||
}; | ||
|
||
Task<SearchBoxDataProviderResult<SearchBoxItem>> ProvideSearchResults(SearchBoxDataProviderRequest request) | ||
{ | ||
SearchBoxDataProviderResult<SearchBoxItem> result = new() | ||
{ | ||
Data = Data.Where(i => i.Title.Contains(request.UserInput, StringComparison.OrdinalIgnoreCase)).ToArray() | ||
}; | ||
|
||
return Task.FromResult(result); | ||
} | ||
|
||
protected override async Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
await _component.FocusAsync(); | ||
} | ||
|
||
class SearchBoxItem | ||
{ | ||
public string Title { get; set; } | ||
public string Subtitle { get; set; } | ||
public BootstrapIcon Icon { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.