Skip to content

Commit

Permalink
Fixes #1984. Setting Label.Visible to false does not hide the Label (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
BDisp authored Sep 5, 2022
1 parent e46813c commit 9505987
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Terminal.Gui/Core/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2562,8 +2562,11 @@ public override bool Visible {
set {
if (base.Visible != value) {
base.Visible = value;
if (!value && HasFocus) {
SetHasFocus (false, this);
if (!value) {
if (HasFocus) {
SetHasFocus (false, this);
}
Clear ();
}
OnVisibleChanged ();
SetNeedsDisplay ();
Expand Down
29 changes: 29 additions & 0 deletions UnitTests/ViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3803,5 +3803,34 @@ e n
", output);
}

[Fact, AutoInitShutdown]
public void Visible_Clear_The_View_Output ()
{
var label = new Label ("Testing visibility.");
var win = new Window ();
win.Add (label);
var top = Application.Top;
top.Add (win);
Application.Begin (top);

Assert.True (label.Visible);
((FakeDriver)Application.Driver).SetBufferSize (30, 5);
GraphViewTests.AssertDriverContentsWithFrameAre (@"
┌────────────────────────────┐
│Testing visibility. │
│ │
│ │
└────────────────────────────┘
", output);

label.Visible = false;
GraphViewTests.AssertDriverContentsWithFrameAre (@"
┌────────────────────────────┐
│ │
│ │
│ │
└────────────────────────────┘
", output);
}
}
}

0 comments on commit 9505987

Please sign in to comment.