AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.12k stars 2.26k forks source link

On Linux keyboard focus remains on owner window after calling ShowDialog #13134

Open rprimora-pricer opened 1 year ago

rprimora-pricer commented 1 year ago

Describe the bug

If I call ShowDialog, keyboard focus remains on the owner window.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new standard Avalonia project targeting Desktop
  2. On the MainWindow that is supplied with Avalonia project template add a couple of input controls like textbox or checkbox.
  3. Add a button that should open a new dialog and add a click event.
  4. Add a new Avalonia Window (lets call it DialogWindow) and place some input controls on it like textbox or checkbox.
  5. On MainWindow click event that you added call await new DialogWindow().ShowDialog(this);
  6. Once the application starts position your focus in first input control of MainWindow just so it has focus.
  7. Now click the button that opens up a dialog.
  8. Now try to use tab to cycle through controls and observer how the focus remains on MainWindow when it should be in the DialogWindow.

Expected behavior

Once a new Window is opened as a dialog it should have the keyboard focus.

Environment

maxkatz6 commented 1 year ago

Related/duplicate https://github.com/AvaloniaUI/Avalonia/issues/2958