Skip to content

[web] when dialog pops up screen reader loses focus instead of focusing on something inside the dialog #138371

Closed
flutter-team-archive/engine
#47727

Description

@yjbanov

When dialog pops up screen reader loses focus instead of focusing on something inside the dialog. The Flutter framework expects that the engine will cause the screen reader to focus on something reasonable automatically. In the case of mobile OSes the screen reader implementations do it for you. On the web, screen readers do nothing, and need assistance from the web engine.

The following test reproduces the issue. The dialog contains two buttons, but when it comes up it does not focus on any of them and does not fire a didGainAccessibilityFocus action (see the last expect statement).

  test('focuses on the first unfocused Focusable', () async {
    semantics()
      ..debugOverrideTimestampFunction(() => _testTime)
      ..semanticsEnabled = true;

    final List<CapturedAction> capturedActions = <CapturedAction>[];
    EnginePlatformDispatcher.instance.onSemanticsActionEvent = (ui.SemanticsActionEvent event) {
      capturedActions.add((event.nodeId, event.type, event.arguments));
    };

    final SemanticsTester tester = SemanticsTester(semantics());
    tester.updateNode(
      id: 0,
      scopesRoute: true,
      transform: Matrix4.identity().toFloat64(),
      children: <SemanticsNodeUpdate>[
        tester.updateNode(
          id: 1,
          children: <SemanticsNodeUpdate>[
            tester.updateNode(
              id: 2,
              label: 'Button 1',
              hasTap: true,
              hasEnabledState: true,
              isEnabled: true,
              isButton: true,
              isFocusable: true,
              isFocused: false,
              rect: const ui.Rect.fromLTRB(0, 0, 100, 50),
            ),
            tester.updateNode(
              id: 3,
              label: 'Button 2',
              hasTap: true,
              hasEnabledState: true,
              isEnabled: true,
              isButton: true,
              isFocusable: true,
              isFocused: false,
              rect: const ui.Rect.fromLTRB(0, 0, 100, 50),
            ),
          ],
        ),
      ],
    );
    tester.apply();

    expect(
      capturedActions,
      <CapturedAction>[
        (2, ui.SemanticsAction.didGainAccessibilityFocus, null),
      ],
    );

    semantics().semanticsEnabled = false;
  });

Activity

  1. added
    engineflutter/engine related. See also e: labels.
    platform-webWeb applications specifically
    P1High-priority issues at the top of the work list
    team-webOwned by Web platform team
    triaged-webTriaged by Web platform team
    on Nov 13, 2023
  2. self-assigned this
    on Nov 13, 2023
  3. github-actions commented on Jan 4, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  4. locked as resolved and limited conversation to collaborators on Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listengineflutter/engine related. See also e: labels.platform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions