1
0

Clear city selection using a component reference.

This commit is contained in:
Kevin Matsubara 2025-03-27 21:36:53 +01:00
parent bdfc834753
commit b14af7616e
2 changed files with 7 additions and 2 deletions

View File

@ -22,6 +22,10 @@
[Parameter]
public EventCallback<string> SelectCityCallBack { get; set; }
public void ClearSelection()
{
this.selectedCity = string.Empty;
}
private void HandleCitySelection(string cityName)
{
this.selectedCity = cityName;

View File

@ -4,7 +4,7 @@
<h3>Servers</h3>
<br/>
<br/>
<CityListComponent SelectCityCallBack="HandleCitySelection"></CityListComponent>
<CityListComponent @ref="cityListComponent" SelectCityCallBack="HandleCitySelection"></CityListComponent>
<br/>
<SearchBarComponent FilterSearchTerm="HandleSearch"></SearchBarComponent>
<br/>
@ -20,6 +20,7 @@
@code {
private string selectedCity = "Eindhoven";
private string searchFilter = "";
private CityListComponent? cityListComponent;
private void HandleCitySelection(string cityName)
{
@ -29,7 +30,7 @@
private void HandleSearch(string searchFilter)
{
this.selectedCity = string.Empty;
this.searchFilter = searchFilter;
cityListComponent?.ClearSelection();
}
}