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

[Bug] ClearButtonVisibility.Never does not take effect on UWP (2) #11946

Closed
omghb opened this issue Aug 28, 2020 · 2 comments · Fixed by #11953
Closed

[Bug] ClearButtonVisibility.Never does not take effect on UWP (2) #11946

omghb opened this issue Aug 28, 2020 · 2 comments · Fixed by #11953
Labels
a/entry i/regression in-progress This issue has an associated pull request that may resolve it! p/UWP t/bug 🐛
Milestone

Comments

@omghb
Copy link

omghb commented Aug 28, 2020

Description

The issue #8836 ClearButtonVisibility.Never does not take effect on UWP is not fixed.

Steps to Reproduce

  1. Clone https://github.com/omghb/XamarinUwpClearButtonVisibilityIssue
  2. Run UWP app
  3. Add characters into the entries

Expected Behavior

In the "ClearButtonVisibility (Default)" and "ClearButtonVisibility (Never)" the clear button should not get visible.

Actual Behavior

In the "ClearButtonVisibility (Default)" and "ClearButtonVisibility (Never)" the clear button gets visible as soon a character was entered and the entry has the focus.

Basic Information

  • Version with issue: "Xamarin.Forms" Version="4.8.0.1269"
  • IDE: VS 2019 16.6.3
  • Platform Target Frameworks:
    • UWP: SDK 10.0.18362.0

Dirty Workaround

[assembly: ExportRenderer(typeof(Entry), typeof(MyEntryRenderer))]
namespace MySample.UWP.Renderer
{
    public class MyEntryRenderer : EntryRenderer
    {
        public MyEntryRenderer()
        {
            ((IVisualNativeElementRenderer)this).ControlChanging += ControlChanging;
            ((IVisualNativeElementRenderer)this).ControlChanged += ControlChanged;
        }

        private void ControlChanging(object sender, EventArgs e)
        {
            if (Control != null)
            {
                Control.Loaded -= ControlLoaded;
            }
        }

        private void ControlChanged(object sender, EventArgs e)
        {
            if (Control != null)
            {
                Control.Loaded += ControlLoaded;
            }
        }

        private void ControlLoaded(object sender, RoutedEventArgs e)
        {
            if (Control is FormsTextBox x)
            {
                var m = typeof(FormsTextBox).GetMethod("ClearButtonVisibleChanged", BindingFlags.NonPublic | BindingFlags.Static);
                m?.Invoke(null, new object[] { x, null });
            }
        }
@omghb omghb added s/unverified New report that has yet to be verified t/bug 🐛 labels Aug 28, 2020
@jsuarezruiz jsuarezruiz added i/regression and removed s/unverified New report that has yet to be verified labels Aug 28, 2020
@bmacombe
Copy link
Contributor

@samhouts I'll take a look this one, I just tested #8836 test page on the latest main and it's still good. Might be an issue when the visibility is set initially in the XAML, my test page sets it after the control has been loaded.

@bmacombe
Copy link
Contributor

Yep, PR on the way

@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Aug 28, 2020
@samhouts samhouts modified the milestones: 5.0.0, 4.8.0 Aug 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/entry i/regression in-progress This issue has an associated pull request that may resolve it! p/UWP t/bug 🐛
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants