Skip to content

Commit 0586108

Browse files
BugFix: Incorrect Site Navigation on Search (#649)
* Remove missing AOT compilation from project configuration * Fixing incorrect condition * Fixing bug in FloorSite not showing due to incorrect binding. * Update search placeholder and refactor search logic - Changed `SearchPlaceholder` to use correct resource "FloorFilterFilterSearchPlaceholder". - Removed unused `InitializeLocalizedStrings` method from `FloorFilter`. - Refactored `HandleSearchText_Changed` in `FloorFilterBrowseSitesPage` for improved search functionality and UI handling.
1 parent d0511cf commit 0586108

File tree

4 files changed

+26
-38
lines changed

4 files changed

+26
-38
lines changed

src/Toolkit/Toolkit.Maui/FloorFilter/FloorFilter.MessageProperties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public string? SearchPlaceholder
3131
/// Identifies the <see cref="SearchPlaceholder"/> bindable property.
3232
/// </summary>
3333
public static readonly BindableProperty SearchPlaceholderProperty =
34-
BindableProperty.Create(nameof(SearchPlaceholder), typeof(string), typeof(FloorFilter), Properties.Resources.GetString("FloorFilterFilter"));
34+
BindableProperty.Create(nameof(SearchPlaceholder), typeof(string), typeof(FloorFilter), Properties.Resources.GetString("FloorFilterFilterSearchPlaceholder"));
3535

3636
/// <summary>
3737
/// Gets or sets the message shown to the user when a list or filtered list is empty.

src/Toolkit/Toolkit.Maui/FloorFilter/FloorFilter.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,6 @@ public FloorFilter()
7272
_controller.PropertyChanged += HandleControllerPropertyChanges;
7373
}
7474

75-
private void InitializeLocalizedStrings()
76-
{
77-
BrowseLabel = Properties.Resources.GetString("FloorFilterBrowse");
78-
BrowseSitesLabel = Properties.Resources.GetString("FloorFilterBrowseSites");
79-
BrowseFacilitiesLabel = Properties.Resources.GetString("FloorFilterBrowseFacilities");
80-
NoResultsMessage = Properties.Resources.GetString("FloorFilterNoResultsFound");
81-
AllFacilitiesLabel = Properties.Resources.GetString("FloorFilterAllFacilities");
82-
SearchPlaceholder = Properties.Resources.GetString("FloorFilterFilter");
83-
}
84-
8575
/// <inheritdoc/>
8676
protected override void OnApplyTemplate()
8777
{

src/Toolkit/Toolkit.Maui/FloorFilter/FloorFilterBrowseSitesPage.cs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -167,32 +167,30 @@ private void HandleListItem_Tapped(object? sender, SelectionChangedEventArgs e)
167167
private void HandleAllSites_Clicked(object? sender, EventArgs e) => _ff?.NavigateForward(new FloorFilterBrowseFacilitiesPage(_ff, true, true));
168168

169169
private void HandleSearchText_Changed(object? sender, TextChangedEventArgs e)
170-
{
171-
if (!string.IsNullOrWhiteSpace(_searchBar.Text))
172-
{
173-
var simplified = _searchBar.Text.ToLower();
174-
var results = _ff?.AllSites?.Where(site => site.Name.ToLower().Contains(simplified));
175-
176-
_filteredListView.ItemsSource = results;
177-
178-
if (results != null)
179-
{
180-
if (_ff?.SelectedSite != null && results.Contains(_ff.SelectedSite))
181-
{
182-
_filteredListView.SelectedItem = _ff.SelectedSite;
183-
}
184-
185-
_unfilteredListView.IsVisible = false;
186-
_filteredListView.IsVisible = results.Any();
187-
}
188-
_noResultLabel.IsVisible = !(results?.Any() == true);
189-
}
190-
else
191-
{
192-
_filteredListView.ItemsSource = null;
193-
_filteredListView.IsVisible = false;
194-
_unfilteredListView.IsVisible = _itemsSource?.Any() == true;
195-
_noResultLabel.IsVisible = !(_itemsSource?.Any() == true);
170+
{
171+
var searchText = _searchBar.Text;
172+
if (!string.IsNullOrWhiteSpace(searchText))
173+
{
174+
var results = _ff?.AllSites?.Where(site =>
175+
site.Name.Contains(searchText, StringComparison.CurrentCultureIgnoreCase));
176+
177+
bool hasResults = results?.Any() ?? false;
178+
179+
_filteredListView.ItemsSource = results;
180+
_filteredListView.SelectedItem = null;
181+
182+
_unfilteredListView.IsVisible = false;
183+
_filteredListView.IsVisible = hasResults;
184+
_noResultLabel.IsVisible = !hasResults;
185+
}
186+
else
187+
{
188+
bool hasItems = _itemsSource?.Any() ?? false;
189+
190+
_filteredListView.ItemsSource = null;
191+
_filteredListView.IsVisible = false;
192+
_unfilteredListView.IsVisible = hasItems;
193+
_noResultLabel.IsVisible = !hasItems;
196194
}
197195
}
198196

src/Toolkit/Toolkit.UI.Controls/FloorFilter/FloorFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private void InitializeLocalizedStrings()
8888
AllFacilitiesLabel = Properties.Resources.GetString("FloorFilterAllFacilities");
8989
BackButtonLabel = Properties.Resources.GetString("FloorFilterBackButton");
9090
AllFloorsLabel = Properties.Resources.GetString("FloorFilterAllFloors");
91-
SearchPlaceholder = Properties.Resources.GetString("FloorFilterFilter");
91+
SearchPlaceholder = Properties.Resources.GetString("FloorFilterFilterSearchPlaceholder");
9292
}
9393

9494
/// <inheritdoc/>

0 commit comments

Comments
 (0)