unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.94k stars 724 forks source link

The flyout is being opened recursively when called from within a TextBox GotFocus Event #15770

Closed rafael-rosa-knowcode closed 8 months ago

rafael-rosa-knowcode commented 8 months ago

Current behavior

The flyout resource is not being closed and is being opened recursively when called from within a TextBox GotFocus Event.

https://github.com/unoplatform/uno/assets/116665025/d4196e10-f39a-4f82-93a0-820d7a12304f

Using this Xaml

      <TextBox Text="Text"
                     PlaceholderText="SomeText" GotFocus="TextBox_GotFocus">
      </TextBox>

      <Button x:Name="FlyoutButton"
                    Grid.Column="1"
                    Width="20"
                    Height="20"
                    Padding="2"
                    Margin="10"
                    DataContext="{Binding}"
                    VerticalAlignment="Center">
        <Viewbox>
          <SymbolIcon Symbol="FullScreen" />
        </Viewbox>
        <Button.Flyout>
          <local:FlyoutPage/>
        </Button.Flyout>
      </Button>

and this CS

    private void TextBox_GotFocus(object sender, RoutedEventArgs e)
    {
        if (!FlyoutButton.Flyout.IsOpen)
        { 
            FlyoutButton.Flyout.ShowAt(FlyoutButton);
        }
    }

Reference Project (Repro)

FlyoutTest.zip

Expected behavior

The expected result is that the flyout has the same behavior as the Button click, when opened from the TextBox using ShowAt.

In other words, it should open and allow iteration. And it doesn't crash the application, without allowing other clicks.

How to reproduce it (as minimally and precisely as possible)

using the wizard. Create a default Recommended project.

Within the recommended project, include the xaml and cs code above and run the application.

Or evaluate the attachment with the project reproducing the situation.

Workaround

using the wizard. Create a default Recommended project.

Within the recommended project, include the xaml and cs code above (current behavior) and run the application.

Or evaluate the attachment with the project reproducing the situation.

Works on UWP/WinUI

Yes

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="NUnit" Version="4.0.1" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Microsoft.Windows.Compatibility" Version="8.0.0" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.4.231219000" />
<PackageVersion Include="SkiaSharp.Skottie" Version="2.88.7" />
<PackageVersion Include="SkiaSharp.Views.Uno.WinUI" Version="2.88.7" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="Uno.Core.Extensions.Logging.Singleton" Version="4.0.1" />
<PackageVersion Include="Uno.Extensions.Core.WinUI" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Configuration" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Hosting" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Hosting.WinUI" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Http" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Http.WinUI" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Http.Refit" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Localization" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Localization.WinUI" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Logging.OSLog" Version="1.7.0" />
<PackageVersion Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.7.0" />
<PackageVersion Include="Uno.Extensions.Logging.WinUI" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Navigation" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Navigation.WinUI" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Navigation.Toolkit.WinUI" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Reactive" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Reactive.WinUI" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Serialization" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Serialization.Http" Version="4.0.0" />
<PackageVersion Include="Uno.Extensions.Serialization.Refit" Version="4.0.0" />
<PackageVersion Include="Uno.Material.WinUI" Version="4.1.1" />
<PackageVersion Include="Uno.Dsp.Tasks" Version="1.2.9" />
<PackageVersion Include="Uno.Toolkit.WinUI" Version="5.1.7" />
<PackageVersion Include="Uno.Toolkit.WinUI.Material" Version="5.1.7" />
<PackageVersion Include="Uno.Resizetizer" Version="1.3.0" />
<PackageVersion Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="$(UnoVersion)" />
<PackageVersion Include="Uno.UniversalImageLoader" Version="1.9.36" />
<PackageVersion Include="Uno.Wasm.Bootstrap" Version="9.0.0-dev.35" />
<PackageVersion Include="Uno.Wasm.Bootstrap.DevServer" Version="9.0.0-dev.35" />
<PackageVersion Include="Uno.Wasm.Bootstrap.Server" Version="9.0.0-dev.35" />
<PackageVersion Include="Uno.WinUI" Version="$(UnoVersion)" />
<PackageVersion Include="Uno.WinUI.Lottie" Version="$(UnoVersion)" />
<PackageVersion Include="Uno.WinUI.DevServer" Version="$(UnoVersion)" />
<PackageVersion Include="Uno.WinUI.Skia.Gtk" Version="$(UnoVersion)" />
<PackageVersion Include="Uno.WinUI.WebAssembly" Version="$(UnoVersion)" />
<PackageVersion Include="Xamarin.Google.Android.Material" Version="1.10.0.2" />
<PackageVersion Include="Uno.UITest.Helpers" Version="1.1.0-dev.70" />
<PackageVersion Include="Xamarin.UITest" Version="4.3.3" />

Affected platforms

WebAssembly, Skia (GTK on Linux/macOS/Windows)

IDE

No response

IDE version

Microsoft Visual Studio Community 2022 (2) (64-bit) - Current Version 17.9.0

Relevant plugins

No response

Anything else we need to know?

There is a recursive call for GotFocus on TextBox.

https://github.com/unoplatform/uno/assets/116665025/597b2280-7ee6-41b0-9446-528d6e5ff513

rafael-rosa-knowcode commented 8 months ago

Reference Project (Repro)

FlyoutTest.zip