1
0

Allow HTML attributes on SearchBar.

This commit is contained in:
Kevin Matsubara 2025-03-28 23:20:00 +01:00
parent ea9213f9c1
commit 23d20f2f04
2 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,4 @@
<div class="input-group mb-3 input-width">
<div class="input-group mb-3 input-width" @attributes="OtherAttributes">
<input type="text" class="form-control" placeholder="Search servers"
@bind-value="serverFilter"
@bind-value:event="oninput" />
@ -18,6 +18,10 @@
[Parameter]
public EventCallback<string> FilterSearchTerm { get; set; }
[Parameter(CaptureUnmatchedValues = true)]
// Enables other HTML attributes like class, style, data-x, etc.
public Dictionary<string, object>? OtherAttributes { get; set; }
private void HandleSearch()
{
FilterSearchTerm.InvokeAsync(serverFilter);

View File

@ -6,7 +6,11 @@
<br/>
<CityListComponent @ref="cityListComponent" SelectCityCallBack="HandleCitySelection"></CityListComponent>
<br/>
<SearchBarComponent @ref="searchBarComponent" FilterSearchTerm="HandleSearch"></SearchBarComponent>
<SearchBarComponent
@ref="searchBarComponent"
FilterSearchTerm="HandleSearch"
style="width: 600px">
</SearchBarComponent>
<br/>
<a href="@($"/servers/add")" class="btn btn-primary">Add</a>
<br/>