Skip to content

iOS accessibility bridge does not detect scope route change correctly #66308

@chunhtai

Description

@chunhtai

Steps to Reproduce

import 'package:flutter/material.dart';
final GlobalKey<NavigatorState> navigator = GlobalKey<NavigatorState>();
void main() {
  runApp(MaterialApp(home:TapBox()));
}

class TapBox extends StatelessWidget {
  TapBox({Key key}) : super(key: key);
 
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        actions: [
          // action button
          IconButton(icon: const BackButtonIcon(), onPressed: () {}),
        ],
      ),
      body: TapboxA(),
    );
  }
}
 
class TapboxA extends StatefulWidget {
  TapboxA({Key key}) : super(key: key);
 
  @override
  _TapboxAState createState() => _TapboxAState();
}
 
class _TapboxAState extends State<TapboxA> {
  bool _active = false;
 
  final pageViewKey = GlobalKey();
  final pageController = PageController(initialPage: 0, viewportFraction: 0.15);
 
  void _handleTap() {
    setState(() {
      _active = !_active;
    });
  }
 
  @override
  Widget build(BuildContext context) {
    return _active
        ? _buildPageView(
      context,
    )
        : Semantics(
            key: ValueKey<int>(1),
            scopesRoute: true,
            explicitChildNodes: true,
            child: Semantics(
              namesRoute: true,
              label: 'PageView widget',
              onTap: _handleTap,
              excludeSemantics: true,
              child: _buildPageView(
                context,
              ),
            )
          );
  }
 
  Widget _buildPageView(BuildContext context) {
    return Semantics(
      key: ValueKey<int>(0),
      scopesRoute: true,
      explicitChildNodes: true,
      child: PageView.builder(
        key: pageViewKey,
        controller: pageController,
        allowImplicitScrolling: true,
        itemCount: 20,
        itemBuilder: (_, index) => _buildItem(
          context,
          index: index,
        ),
      )
    );
  }
 
  Widget _buildItem(
      BuildContext context, {
        int index,
      }) {
    return Semantics(
      label: 'label',
      namesRoute: true,
      button: true,
      excludeSemantics: true,
      onTap: () async {
        await _animateToPage(index);
        _handleTap();
      },
      child: Center(child: const Text('text')),
    );
  }
 
  Future<void> _animateToPage(int page) {
    return pageController.animateToPage(
      page,
      duration: const Duration(milliseconds: 400),
      curve: Curves.easeInOut,
    );
  }
}
  1. iOS voice over on
  2. tap the pageview widget
  3. double tap to trigger on tap event
    4, the focus go to the first text
  4. double tap to trigger on tap

expect: it should announce pageview widget
action: nothing is announced

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)customer: money (g3)engineflutter/engine related. See also e: labels.platform-iosiOS applications specificallywaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions