Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Windows SearchBar MaxLength > 0 not working properly. #24919

Merged
merged 32 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
70cb172
Fix Windows SearchBar MaxLength property
jsuarezruiz May 26, 2022
63af992
Fix issue
jsuarezruiz May 26, 2022
19dc864
fix-5669-Fix for Windows SearchBar MaxLength > 0 not working properly.
BagavathiPerumal Sep 25, 2024
cb22256
fix-5669-Taking child for AutoSuggestBox code has been moved to Searc…
BagavathiPerumal Sep 25, 2024
62c34a8
fix-5669-Removed unwanted parameter UpdateMaxLength().
BagavathiPerumal Sep 25, 2024
6f8cbe7
fix-5669-Changes committed for PublicAPI file.
BagavathiPerumal Sep 25, 2024
b857985
fix-5669-Getting Child of TextBox using GetChildren() method instead …
BagavathiPerumal Sep 25, 2024
ce2a9ac
fix-5669-Optimized the code in the UpdateMaxLength() method.
BagavathiPerumal Sep 25, 2024
137996f
fix-5669-Removed Child count check for AutoSuggestBox Control.
BagavathiPerumal Sep 25, 2024
dc05c0f
fix-5669-Updated the proper naming for the variable.
BagavathiPerumal Sep 25, 2024
37071e8
Fix-5669-Removed unwanted space.
BagavathiPerumal Sep 26, 2024
7901c62
fix-5669-Added missing namespace.
BagavathiPerumal Sep 27, 2024
26f5eff
fix-5669-Fix for Windows SearchBar MaxLength > 0 not working properly.
BagavathiPerumal Sep 25, 2024
2cc4c59
fix-5669-Taking child for AutoSuggestBox code has been moved to Searc…
BagavathiPerumal Sep 25, 2024
3259e10
fix-5669-Removed unwanted parameter UpdateMaxLength().
BagavathiPerumal Sep 25, 2024
8d49a11
fix-5669-Changes committed for PublicAPI file.
BagavathiPerumal Sep 25, 2024
0096d10
fix-5669-Getting Child of TextBox using GetChildren() method instead …
BagavathiPerumal Sep 25, 2024
ce5ceb2
fix-5669-Optimized the code in the UpdateMaxLength() method.
BagavathiPerumal Sep 25, 2024
6aab5aa
fix-5669-Removed Child count check for AutoSuggestBox Control.
BagavathiPerumal Sep 25, 2024
a7e1d18
fix-5669-Updated the proper naming for the variable.
BagavathiPerumal Sep 25, 2024
c03e3eb
Fix-5669-Removed unwanted space.
BagavathiPerumal Sep 26, 2024
d5b7e0a
fix-5669-Added missing namespace.
BagavathiPerumal Sep 27, 2024
652ea80
Merge branch 'main' of https://github.com/BagavathiPerumal/maui into …
BagavathiPerumal Sep 27, 2024
ca1155f
Merge branch 'fix-5669' of https://github.com/BagavathiPerumal/maui i…
BagavathiPerumal Sep 27, 2024
3a43d48
fix-5669-Added testcase images.
BagavathiPerumal Sep 30, 2024
0c2dc9c
fix-5669-Updated testcase images.
BagavathiPerumal Oct 3, 2024
574edb8
Merge branch 'main' of https://github.com/BagavathiPerumal/maui into …
BagavathiPerumal Oct 3, 2024
5db5467
fix-5669-Removed the Linq related codes.
BagavathiPerumal Oct 4, 2024
529e18b
Merge branch 'dotnet:fix-5669' into fix-5669
BagavathiPerumal Oct 7, 2024
dd429a6
fix-5669-Unwanted code removed.
BagavathiPerumal Oct 7, 2024
c9ef443
Merge branch 'main' of https://github.com/BagavathiPerumal/maui into …
BagavathiPerumal Oct 7, 2024
e7fd77f
fix-5669-Updated iOS testcase image.
BagavathiPerumal Oct 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue5669.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue5669">
<ContentPage.Content>
<StackLayout>
<SearchBar x:Name="searchbar" Text="Searchbar Control" MaxLength="3" AutomationId="SearchBar"/>
<HorizontalStackLayout>
<Label Text="MaxLength value is: "/>
<Label Text="{Binding Source={x:Reference searchbar}, Path=MaxLength}"/>
</HorizontalStackLayout>
<Button AutomationId="ChangeValue" Text="Change Value" x:Name="button" Clicked="Button_Clicked"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
17 changes: 17 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue5669.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 5669, "Windows SearchBar MaxLength > 0 not working properly", PlatformAffected.UWP)]
public partial class Issue5669 : ContentPage
{
public Issue5669()
{
InitializeComponent();
}

private void Button_Clicked(object sender, EventArgs e)
{
searchbar.MaxLength = 4;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#if !MACCATALYST
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue5669: _IssuesUITest
{
public override string Issue => "Windows SearchBar MaxLength > 0 not working properly";
public Issue5669(TestDevice testDevice) : base(testDevice)
{
}

[Test]
[Category(UITestCategories.SearchBar)]
public void SearchBarMaxLength()
{
App.WaitForElement("SearchBar");
App.EnterText("SearchBar", "r");
App.Click("ChangeValue");
App.EnterText("SearchBar", "r");
App.EnterText("SearchBar", "c");
VerifyScreenshot();
}
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/Core/src/Platform/Windows/SearchBarExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ public static void UpdateMaxLength(this AutoSuggestBox platformControl, ISearchB
if (maxLength == -1)
maxLength = int.MaxValue;

var children = platformControl.GetChildren<TextBox>();
if (children is not null)
{
foreach (var textBox in children)
{
if (textBox is not null)
{
textBox.MaxLength = searchBar.MaxLength;
break;
}
}
}

if (maxLength == 0)
MauiAutoSuggestBox.SetIsReadOnly(platformControl, true);
else
Expand Down
Loading