#22060·Avalonia

On Wayland, Keybinding with KeyGestures may repeat "infinitely" if bound command opens window

Author: carl-andersson-at-westermoCreated Aug 25, 2026Updated Sep 15, 2026
Labelsbug

Describe the bug

When running an Avalonia app, specifically when using .UseWaylandWithFallback(), using a keybinding with a keygesture, i.e:

csharp
public MainWindow()
{
      InitalizeComponent();
      KeyBindings.Add(new KeyBinding
      {
          Gesture = new KeyGesture(Key.Delete),
          Command = new CommandImpl(OnDelete)
      });
}

If OnDelete creates a window, i.e

csharp
private async void OnDelete()
{
      var window = new Window();
      await window.ShowDialog(this);
} 

Then once windowcloses, OnDelete will seemingly immediately execute again, spawning a new window, and so on until the program terminates by other means.

This does not seem to happen on X11 or Windows, and the stack trace points to Avalonia.Wayland.WindowImpl.Sink.OnKeyRepeatTick being the source of each new OnDelete call

To Reproduce

Minial repro project attached, run (on a wayland-machine), focus window, and press delete.

AvaloniaRepeatBugRepro.zip

Expected behavior

OnDelete should not be reentrant on window close.

Avalonia version

12.1.1

OS

Linux

Additional context

No response