Repository: flutter
Issue: [web][a11y] `autofocus` causes Safari to lose semantics
Labels: framework,a: accessibility,platform-web,f: focus,browser: safari-macos,P2,customer: troy,team-web,triaged-web

## Steps to Reproduce

1. Execute `flutter run -d chrome` on the code sample.
2. Open the application in Safari and enable VoiceOver.
3. Use **VO** + **Space** to click the **Page 2** button.
4. Use **VO** + **Space** to click the **Page 1** button.
5. Try and use **VO** + **Space** to click the **Page 2** button or to check the **Check me** checkbox.

**Expected results:**

The semantics of the **Page 2** button and the **Check me** checkbox should be preserved and the screen reader should be able to interact with the elements.

**Actual results:** <!-- what did you see? -->

The semantics are lost and the screen reader reads the elements as groups (see the attached video). Setting `autofocus: false` on the first button resolves this issue.

<details>
<summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  // Auto-enable accessibility for our Blind and Low Vision customers (see
  // https://docs.flutter.dev/development/accessibility-and-localization/accessibility#screen-readers).
  RendererBinding.instance.setSemanticsEnabled(true);

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Safari A11y Issue',
      initialRoute: Page1.routeName,
      routes: {
        Page1.routeName: (_) => const Page1(),
        Page2.routeName: (_) => const Page2(),
      },
    );
  }
}

class Page1 extends StatefulWidget {
  const Page1({Key? key}) : super(key: key);

  static const String routeName = '/page1';

  @override
  State<Page1> createState() => _Page1State();
}

class _Page1State extends State<Page1> {
  bool _checkboxValue = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Page 1'),
      ),
      body: Column(
        children: <Widget>[
          TextButton(
            autofocus: true, // On Safari, this can result in other widgets losing their semantics.
            onPressed: () => Navigator.pushReplacementNamed(context, Page2.routeName),
            child: const Text('Page 2 (autofocus)'),
          ),
          TextButton(
            onPressed: () => Navigator.pushReplacementNamed(context, Page2.routeName),
            child: const Text('Page 2'),
          ),
          CheckboxListTile(
            onChanged: (bool? newValue) => setState(() => _checkboxValue = newValue!),
            title: const Text('Check me'),
            value: _checkboxValue,
          ),
        ],
      ),
    );
  }
}

class Page2 extends StatelessWidget {
  const Page2({Key? key}) : super(key: key);

  static const String routeName = '/page2';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Page 2'),
      ),
      body: Column(
        children: <Widget>[
          TextButton(
            onPressed: () => Navigator.pushReplacementNamed(context, Page1.routeName),
            child: const Text('Page 1'),
          ),
        ],
      ),
    );
  }
}
```
</details>

<details>
  <summary>Logs</summary>

```
[✓] Flutter (Channel stable, 3.0.4, on macOS 12.4 21F79 darwin-x64, locale en-US)
    • Flutter version 3.0.4 at /Users/vsomayaji/Dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 85684f9300 (13 days ago), 2022-06-30 13:22:47 -0700
    • Engine revision 6ba2af10bb
    • Dart version 2.17.5
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/vsomayaji/Library/Android/sdk
    • Platform android-31, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.4 21F79 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 103.0.5060.114

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```
</details>


https://user-images.githubusercontent.com/1007109/178851506-8ff2b13d-2675-4708-b58c-4f393d73739f.mov