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

WinUI 3 custom title bar captures focus from flyouts #9463

Open
kjean667 opened this issue Mar 19, 2024 · 5 comments
Open

WinUI 3 custom title bar captures focus from flyouts #9463

kjean667 opened this issue Mar 19, 2024 · 5 comments
Labels
area-Flyouts area-Popup area-Windowing bug Something isn't working team-Controls Issue for the Controls team

Comments

@kjean667
Copy link

Describe the bug

When using a custom title bar that extends own content into the title bar, flyouts that are opened from the page UI over the custom title bar receive no input.
The mouse input is interpreted as a hover and click on the title bar, not on the items in the flyout.
Trying to click on or select the top item in the flyout is impossible and is instead interpreted as a window movement when clicking and dragging.
Double-clicking on the top flyout item maximizes the window instead of selecting the flyout item.

Also, the title bar control buttons for minimize, maximize and closing the window are given priority over the flyout that is displayed above.

Steps to reproduce the bug

Reproduction sample code is available here: https://github.com/kjean667/WinUICustomTitleAndFlyoutBug

Use AppWindowTitleBar.ExtendsContentIntoTitleBar and SetDragRectangles to extend custom content into the title bar of the window.
(See WindowTitleHelper.cs in reproduction sample)

Use a simple XAML Window with a Flyout that is tall enough to open over the custom title bar. The Window needs to be the exact right size so that the Flyout is extended over the title bar content.

<Window
  x:Class="WinUICustomTitleBarInhibitsControlInput.MainWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d">

  <Grid RowDefinitions="80,*">

    <StackPanel x:Name="MenuBarContent" Grid.Row="0" Background="DarkBlue" Padding="16">
      <TextBlock Text="Custom Title Bar" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
    </StackPanel>

    <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
      <Button Content="Click Me">
        <Button.Flyout>
          <Flyout Placement="Right">
            <ListView>
              <ListView.Items>
                <ListViewItem>Item 1</ListViewItem>
                <ListViewItem>Item 2</ListViewItem>
                <ListViewItem>Item 3</ListViewItem>
                <ListViewItem>Item 4</ListViewItem>
                <ListViewItem>Item 5</ListViewItem>
                <ListViewItem>Item 6</ListViewItem>
                <ListViewItem>Item 7</ListViewItem>
                <ListViewItem>Item 8</ListViewItem>
                <ListViewItem>Item 9</ListViewItem>
              </ListView.Items>
            </ListView>
          </Flyout>
        </Button.Flyout>
      </Button>

    </StackPanel>
  </Grid>
</Window>

Expected behavior

The first item in the flyout shall be clickable and when hovering over the item the focus background shall be displayed.

Screenshots

WinUICustomTitleBarInhibitsControlInput

NuGet package version

WinUI 3 - Windows App SDK 1.5.1: 1.5.240311000

Windows version

No response

Additional context

Windows 11 23H2 (22631.3155)

@kjean667 kjean667 added the bug Something isn't working label Mar 19, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Mar 19, 2024
@Gaoyifei1011
Copy link

Describe the bug

When using a custom title bar that extends own content into the title bar, flyouts that are opened from the page UI over the custom title bar receive no input. The mouse input is interpreted as a hover and click on the title bar, not on the items in the flyout. Trying to click on or select the top item in the flyout is impossible and is instead interpreted as a window movement when clicking and dragging. Double-clicking on the top flyout item maximizes the window instead of selecting the flyout item.

Also, the title bar control buttons for minimize, maximize and closing the window are given priority over the flyout that is displayed above.

Steps to reproduce the bug

Reproduction sample code is available here: https://github.com/kjean667/WinUICustomTitleAndFlyoutBug

Use AppWindowTitleBar.ExtendsContentIntoTitleBar and SetDragRectangles to extend custom content into the title bar of the window. (See WindowTitleHelper.cs in reproduction sample)

Use a simple XAML Window with a Flyout that is tall enough to open over the custom title bar. The Window needs to be the exact right size so that the Flyout is extended over the title bar content.

<Window
  x:Class="WinUICustomTitleBarInhibitsControlInput.MainWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d">

  <Grid RowDefinitions="80,*">

    <StackPanel x:Name="MenuBarContent" Grid.Row="0" Background="DarkBlue" Padding="16">
      <TextBlock Text="Custom Title Bar" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
    </StackPanel>

    <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
      <Button Content="Click Me">
        <Button.Flyout>
          <Flyout Placement="Right">
            <ListView>
              <ListView.Items>
                <ListViewItem>Item 1</ListViewItem>
                <ListViewItem>Item 2</ListViewItem>
                <ListViewItem>Item 3</ListViewItem>
                <ListViewItem>Item 4</ListViewItem>
                <ListViewItem>Item 5</ListViewItem>
                <ListViewItem>Item 6</ListViewItem>
                <ListViewItem>Item 7</ListViewItem>
                <ListViewItem>Item 8</ListViewItem>
                <ListViewItem>Item 9</ListViewItem>
              </ListView.Items>
            </ListView>
          </Flyout>
        </Button.Flyout>
      </Button>

    </StackPanel>
  </Grid>
</Window>

Expected behavior

The first item in the flyout shall be clickable and when hovering over the item the focus background shall be displayed.

Screenshots

WinUICustomTitleBarInhibitsControlInput WinUICustomTitleBarInhibitsControlInput

NuGet package version

WinUI 3 - Windows App SDK 1.5.1: 1.5.240311000

Windows version

No response

Additional context

Windows 11 23H2 (22631.3155)

You could set flyout shouldconstraintorootbounds false

@kjean667
Copy link
Author

When using Flyout.ShouldConstrainToRootBounds="False", it works around the problem and items can be selected, but it still does not solve the original issue. Using unconstrained flyouts trigger other crashes in WinUI when trying to hide the flyout from code behind. In that case a native 0x80070057 "The parameter is incorrect" exception is thrown and crashing the application.

@ghost1372
Copy link
Contributor

dup
#9448

@bpulliam bpulliam added team-CompInput Issue for IXP (Composition, Input) team area-Windowing area-Flyouts team-Controls Issue for the Controls team area-Popup and removed needs-triage Issue needs to be triaged by the area owners team-CompInput Issue for IXP (Composition, Input) team labels Mar 22, 2024
@codendone
Copy link
Contributor

For non-windowed flyouts, it might be good for flyout positioning code to ensure the flyout doesn't overlap the titlebar area. Or, alternatively, maybe the flyout could use InputNonClientPointerSource to ensure it gets input even if it is in the titlebar area.

@ghost1372
Copy link
Contributor

For non-windowed flyouts, it might be good for flyout positioning code to ensure the flyout doesn't overlap the titlebar area. Or, alternatively, maybe the flyout could use InputNonClientPointerSource to ensure it gets input even if it is in the titlebar area.

Is there any sample?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Flyouts area-Popup area-Windowing bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

5 participants