Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 91b883e

Browse files
authored
Fix initial load when WhileEditing (#12765)
1 parent 640377c commit 91b883e

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue8836.cs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,25 @@ protected override void Init()
1414
stack.Children.Add(new Label {Text = "Click the button to toggle the clear button visibility."});
1515
stack.Children.Add(new Label { Text = "The default state when this page loaded is NEVER. The clear button should not be visible until you click toggle." });
1616

17-
Entry = new Entry
17+
EntryToggle = new Entry
1818
{
19-
Text = "Clear Button: Never",
19+
Text = "Clear Button: Never (toggles)",
2020
ClearButtonVisibility = ClearButtonVisibility.Never
2121
};
22-
stack.Children.Add(Entry);
22+
stack.Children.Add(EntryToggle);
23+
24+
EntryNever = new Entry
25+
{
26+
Text = "Clear Button: Never (Default Entry ClearButtonVisibility)"
27+
};
28+
stack.Children.Add(EntryNever);
29+
30+
EntryAlways = new Entry
31+
{
32+
Text = "Clear Button: Always (Set before load)",
33+
ClearButtonVisibility = ClearButtonVisibility.WhileEditing
34+
};
35+
stack.Children.Add(EntryAlways);
2336

2437
var button = new Button { Text = "Toggle Clear Button State" };
2538
button.Clicked += Button_Clicked;
@@ -28,22 +41,24 @@ protected override void Init()
2841
Content = stack;
2942
}
3043

31-
private void Button_Clicked(object sender, System.EventArgs e)
44+
void Button_Clicked(object sender, System.EventArgs e)
3245
{
33-
if (Entry.ClearButtonVisibility == ClearButtonVisibility.Never)
46+
if (EntryToggle.ClearButtonVisibility == ClearButtonVisibility.Never)
3447
{
35-
Entry.ClearButtonVisibility = ClearButtonVisibility.WhileEditing;
36-
Entry.Text = "Clear Button: While Editing";
48+
EntryToggle.ClearButtonVisibility = ClearButtonVisibility.WhileEditing;
49+
EntryToggle.Text = "Clear Button: While Editing (toggles)";
3750
}
3851
else
3952
{
40-
Entry.ClearButtonVisibility = ClearButtonVisibility.Never;
41-
Entry.Text = "Clear Button: Never";
53+
EntryToggle.ClearButtonVisibility = ClearButtonVisibility.Never;
54+
EntryToggle.Text = "Clear Button: Never (toggles)";
4255
}
43-
Entry.Focus();
56+
EntryToggle.Focus();
4457
}
4558

46-
public Entry Entry { get; set; }
59+
public Entry EntryToggle { get; set; }
60+
public Entry EntryAlways { get; set; }
61+
public Entry EntryNever { get; set; }
4762

4863
}
4964
}

Xamarin.Forms.Platform.UAP/FormsTextBox.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ void UpdateClearButtonVisible()
397397
{
398398
if (ClearButtonVisible && !states.Contains(visibleState))
399399
states.Add(visibleState);
400-
else
400+
else if(!ClearButtonVisible)
401401
states.Remove(visibleState);
402402
}
403403
}

0 commit comments

Comments
 (0)