Skip to content

Commit 7526be5

Browse files
Updated suggestion
1 parent d7562ae commit 7526be5

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSearchView.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ void OnTextBlockItemClicked(object sender, AdapterView.ItemClickEventArgs e)
355355
_textBlock.Text = "";
356356
SearchConfirmed?.Invoke(this, EventArgs.Empty);
357357
Controller.ItemSelected(item);
358-
Controller.QueryConfirmed();
359358
}
360359

361360
void UpdateClearButtonState()

src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,12 +1058,8 @@ void OnSearchItemSelected(object? sender, object e)
10581058
return;
10591059
}
10601060

1061+
(SearchHandler as ISearchHandlerController)?.ItemSelected(e);
10611062
_searchController.Active = false;
1062-
if (SearchHandler is ISearchHandlerController controller)
1063-
{
1064-
controller.ItemSelected(e);
1065-
controller.QueryConfirmed();
1066-
}
10671063
}
10681064

10691065
void SearchButtonClicked(object? sender, EventArgs e)

src/Controls/src/Core/Shell/SearchHandler.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Windows.Input;
77
using Microsoft.Maui.Controls.Internals;
88
using Microsoft.Maui.Graphics;
9+
using Microsoft.Maui.Devices;
910
using static Microsoft.Maui.Controls.VisualElement;
1011

1112
namespace Microsoft.Maui.Controls
@@ -314,6 +315,12 @@ void ISearchHandlerController.ItemSelected(object obj)
314315
{
315316
OnItemSelected(obj);
316317
SetValue(SelectedItemPropertyKey, obj, specificity: SetterSpecificity.FromHandler);
318+
if (!(DeviceInfo.Platform == DevicePlatform.WinUI))
319+
{
320+
// For WinUI the query is confirmed in the QuerySubmitted event,
321+
// so we don't want to call OnQueryConfirmed here as it would cause the command to execute twice
322+
OnQueryConfirmed();
323+
}
317324
}
318325

319326
void ISearchHandlerController.QueryConfirmed()

0 commit comments

Comments
 (0)