Skip to content

Dialog: on Android, keyboard focus isn't moved into an open dialog and Tab reaches the screen behind it #5296

Open

Description

@Doberjohn

Current behaviour

On Android with a hardware keyboard, opening a Dialog leaves no view with keyboard focus. Tab then moves through the buttons of the screen behind the scrim before it reaches the dialog's hidden close button and its actions, and Enter on a button behind the dialog presses it (on the example app's Dialog screen it opened a second dialog on top of the first). The screen behind is hidden from TalkBack, so with TalkBack on nothing is spoken while focus is there. On web, focus moves into the dialog and Tab stays inside it. 6.0.0-alpha.3 has the same Tab order.

Expected behaviour

As on web: focus moves into the dialog when it opens, Tab stays inside it, and the screen behind can't be reached or pressed while the dialog is open.

How to reproduce?

  1. On Android with a hardware keyboard, render a screen with a few buttons and a Dialog that one of them opens:
<Button onPress={() => setVisible(true)}>Open</Button>
<Button onPress={() => {}}>Behind</Button>
<Dialog
  visible={visible}
  onDismiss={hide}
  title="Alert"
  actions={[
    <Button key="ok" mode="text" onPress={hide}>
      OK
    </Button>,
  ]}
/>
  1. Open the dialog (tap or Enter), press Tab several times, then press Enter when "Behind" has focus.

Related: #5203 (where TalkBack's focus lands on Android).

Your Environment

software version
android 13 (emulator), hardware keyboard
react-native 0.88.1 (New Architecture)
react-native-paper 6.0.0-alpha.4 (main at 7ab2640)
expo sdk 58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions