Skip to content

Android: Back while a dialog is open sends the app to the background instead of closing the dialog #108

Closed

Description

@compot-dev

On an Android TV 16 emulator (API 36, system-images;android-36;android-tv;x86_64), Back while a mobile dialog is open sends the app to the background instead of closing the dialog. Seen with Add camera opened from the Welcome sheet and from the toolbar Add button, on main plus #99 (before #106), with adb shell input keyevent BACK. Back from a camera page does go back to the list, so MainView.OnBackRequested → MainWindowViewModel.TryGoBack is reached there; with a dialog open, OverlayDialogPresenter.TryDismissTopmost should take it first, but the app goes to the background.

Not yet checked: a phone on API 36 and older Android versions, a physical remote.

Expected: Back closes the topmost dialog (as TryGoBack documents), and only at the root sends the app to the background.

Activity

  1. compot-dev commented on Nov 5, 2026

    @compot-dev
    CollaboratorAuthor

    Root cause, reproduced on main (b5e1193) on the Android TV 16 emulator: Back does not skip the dialog, it closes it and then acts a second time.

    Avalonia on Android maps Keycode.Back to Key.Escape (AndroidKeyboardDevice.cs:211), so the key event reaches Button.RootCancelKeyDown, and IsCancel on the Cancel button in CameraEditorContent closes the form. 16–50 ms later the same press arrives through OnBackInvoked: no dialog is open any more, TryGoBack returns false at the root, and the app goes to the background.

    It reproduced only on Add camera, the one form with IsCancel: by tap, D-pad and from Welcome. Discovery, Camera groups and Welcome close correctly and the app stays in front.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions