Fixes #4127. PopupAutocomplete visible not updating when there are no suggestions (#4128)

* Fixes #4127. PopupAutocomplete visible not updating when there are no suggestions

* Code cleanup for re-run git actions
This commit is contained in:
BDisp
2025-06-09 21:30:57 +01:00
committed by GitHub
parent e1086a45a9
commit 2d72425ee3
2 changed files with 19 additions and 10 deletions

View File

@@ -11,8 +11,8 @@ public abstract partial class PopupAutocomplete : AutocompleteBase
private bool _closed;
private Scheme _scheme;
private View _hostControl;
private View _top; // The _hostControl's SuperView
private View _popup;
private View _top; // The _hostControl's SuperView
internal View _popup;
private int _toRenderLength;
/// <summary>Creates a new instance of the <see cref="PopupAutocomplete"/> class.</summary>
@@ -70,6 +70,7 @@ public abstract partial class PopupAutocomplete : AutocompleteBase
{
_top.Initialized += _top_Initialized;
}
_top.Removed += _top_Removed;
}
}
@@ -268,7 +269,11 @@ public abstract partial class PopupAutocomplete : AutocompleteBase
else if (!Visible || HostControl?.HasFocus == false || Suggestions.Count == 0)
{
LastPopupPos = null;
Visible = false;
if (Visible)
{
Close ();
}
if (Suggestions.Count == 0)
{
@@ -372,16 +377,16 @@ public abstract partial class PopupAutocomplete : AutocompleteBase
if (PopupInsideContainer)
{
_popup.Frame = new (
new (HostControl.Frame.X + renderAt.X, HostControl.Frame.Y + renderAt.Y),
new (width, height)
);
new (HostControl.Frame.X + renderAt.X, HostControl.Frame.Y + renderAt.Y),
new (width, height)
);
}
else
{
_popup.Frame = new (
renderAt with { X = HostControl.Frame.X + renderAt.X },
new (width, height)
);
renderAt with { X = HostControl.Frame.X + renderAt.X },
new (width, height)
);
}
_popup.Move (0, 0);
@@ -419,6 +424,7 @@ public abstract partial class PopupAutocomplete : AutocompleteBase
ClearSuggestions ();
Visible = false;
_closed = true;
//RemovePopupFromTop ();
_popup.Visible = false;
HostControl?.SetNeedsDraw ();
@@ -561,7 +567,6 @@ public abstract partial class PopupAutocomplete : AutocompleteBase
_top?.Remove (_popup);
_popup.Dispose ();
_popup = null;
}
}
@@ -571,6 +576,7 @@ public abstract partial class PopupAutocomplete : AutocompleteBase
{
_top = sender as View;
}
AddPopupToTop ();
}

View File

@@ -153,6 +153,9 @@ This an long line and against TextView.
This an long line and against TextView.",
output
);
Assert.Empty (tv.Autocomplete.Suggestions);
Assert.False (((PopupAutocomplete)tv.Autocomplete)._popup.Visible);
top.Dispose ();
}