Skip to content

IOS focus stuck when semantic tree changes #64339

@chunhtai

Description

@chunhtai

b/165881203

Steps to Reproduce

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: Scaffold(
  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(
            label: 'PageView widget',
            onTap: _handleTap,
            excludeSemantics: true,
            child: _buildPageView(
              context,
            ),
          );
  }
 
  Widget _buildPageView(BuildContext context) {
    return 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',
      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. voiceover on, focus pageview widget
  2. double click, the focus goes to item1
  3. swipe right to focus second item, double tap
  4. The focus stuck in a weird place for 10+ second before refocus back pageview widget.

Logs

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)customer: money (g3)platform-iosiOS applications specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions