Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty popup behavior changed in 11.2.0 #17843

Open
Genteure opened this issue Dec 29, 2024 · 1 comment
Open

Empty popup behavior changed in 11.2.0 #17843

Genteure opened this issue Dec 29, 2024 · 1 comment
Labels
bug help-wanted A contribution from the community would be most welcome. os-linux

Comments

@Genteure
Copy link

Genteure commented Dec 29, 2024

Describe the bug

<Popup Name="MyPopup">
    <Panel Background="LightBlue" />
</Popup>

This Popup shows nothing in Avalonia version < 11.2.0 (for example, 11.1.5).
It shows a 300x200 rectangle in Avalonia version >= 11.2.0. It seems to always at the top left of the screen regardless of PlacementTarget.

image

To Reproduce

https://github.com/Genteure/avalonia-linux-empty-popup

Or if the repository is deleted in the future:

Repro steps

Run dotnet new avalonia.app (Avalonia.Templates version 11.2.1.1 but this shouldn't matter too much)

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFrameworks>net8.0;net9.0</TargetFrameworks>
    <Nullable>enable</Nullable>
    <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
  </PropertyGroup>

  <PropertyGroup>
    <AvaloniaVersion Condition="'$(AvaloniaVersion)' == ''">11.2.0</AvaloniaVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
    <PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
    <PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
    <PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaVersion)" />
    <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
    <PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)">
      <IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
      <PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
    </PackageReference>
  </ItemGroup>
</Project>
<Window ......>
    <StackPanel Margin="5">
        <TextBlock Name="RuntimeInfo" />
        <Button Click="TogglePopup" Content="Toggle Popup" />
        <TextBlock Name="PopupIsOpenStatus" />
        <Popup Name="MyPopup">
            <Panel Background="LightBlue" />
        </Popup>
    </StackPanel>
</Window>
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();

        var currentDotnetVersion = Environment.Version;
        var currentAvaloniaVersion = typeof(Button).Assembly.GetName().Version;
        RuntimeInfo.Text = $"Running on .NET {currentDotnetVersion} and Avalonia {currentAvaloniaVersion}";
    }

    private void TogglePopup(object sender, RoutedEventArgs e)
    {
        MyPopup.IsOpen ^= true;

        var panel = (Panel)MyPopup.Child!;
        PopupIsOpenStatus.Text = $"Popup is currently {(MyPopup.IsOpen ? "open" : "closed")}\nPopup.PlacementTarget: {MyPopup.PlacementTarget}\n" +
            $"\nHeight: {panel.Height}\nWidth: {panel.Width}" +
            $"\nDesiredSize: {panel.DesiredSize}\nBounds: {panel.Bounds}";
    }
}
dotnet run -f net8.0 -p:AvaloniaVersion=11.2.0
dotnet run -f net8.0 -p:AvaloniaVersion=11.1.5

Expected behavior

I have not tested this in other OS but the behavior should match.

Avalonia version

11.2.0

OS

Linux

Additional context

amwx/FluentAvalonia#634

300, 200 seems to be coming from Avalonia.X11/X11Window.cs.

PopupRoot got two commits in 11.2.0: 1cfa82 and b27228.

@Genteure Genteure added the bug label Dec 29, 2024
@Genteure
Copy link
Author

I've heard this also happens on macOS but the popup window size is a lot bigger. I don't own any Apple devices so I can't test myself.

@Genteure Genteure changed the title Empty popup behavior on Linux changed in 11.2.0 Empty popup behavior changed in 11.2.0 Dec 29, 2024
@maxkatz6 maxkatz6 added help-wanted A contribution from the community would be most welcome. os-linux labels Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help-wanted A contribution from the community would be most welcome. os-linux
Projects
None yet
Development

No branches or pull requests

2 participants