Skip to content

Commit aa2bddd

Browse files
authored
Set SmartHint.IsContentNullOrEmpty on initial load (#3915)
* update SmartHint.IsContentNullOrEmpty on initial load * added test case
1 parent 49b362a commit aa2bddd

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/MaterialDesignThemes.Wpf/SmartHint.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ private void RefreshState(bool useTransitions)
253253
if (proxy is null) return;
254254
if (!proxy.IsVisible) return;
255255

256+
IsContentNullOrEmpty = proxy.IsEmpty();
257+
256258
var action = new Action(() =>
257259
{
258260
string state = string.Empty;

tests/MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,33 @@ await Wait.For(async() =>
585585

586586
recorder.Success();
587587
}
588+
589+
[Test]
590+
[Description("Issue 3914")]
591+
public async Task TextBox_ClearButtonRemainsHidden_WhenInitiallyCollapsedAndMadeVisible()
592+
{
593+
await using var recorder = new TestRecorder(App);
594+
595+
var grid = await LoadXaml<Grid>($"""
596+
<Grid Margin="30">
597+
<TextBox Visibility="Collapsed"
598+
VerticalAlignment="Center"
599+
materialDesign:TextFieldAssist.HasClearButton="True">
600+
</TextBox>
601+
</Grid>
602+
""");
603+
604+
var textBox = await grid.GetElement<TextBox>("/TextBox");
605+
606+
await textBox.SetVisibility(Visibility.Visible);
607+
608+
var clearButton = await grid.GetElement<Button>("PART_ClearButton");
609+
Visibility clearButtonVisibility = await clearButton.GetVisibility();
610+
611+
await Assert.That(clearButtonVisibility).IsEqualTo(Visibility.Collapsed);
612+
613+
recorder.Success();
614+
}
588615
}
589616

590617
public class NotEmptyValidationRule : ValidationRule

0 commit comments

Comments
 (0)