Skip to content

[Web] : TextField loose focus after navigation #71476

@karabanovbs

Description

@karabanovbs

When i user pushReplacement the TextField on second screen loose focus. On android work correctly, problem reproduce on IOS and WEB.

With push navigation (without replacement) work correctly.

Steps to Reproduce

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Screen 1'),
        ),
        body: Builder(
          builder: (context) {
            return AutofillGroup(
              child: TextFormField(
                autofocus: true,
                onChanged: (value) {
                  Navigator.of(context).pushReplacement(MaterialPageRoute(
                    builder: (context) {
                      return Scaffold(
                        appBar: AppBar(
                          title: Text('Screen 2'),
                        ),
                        body: TextField(
                          autofocus: true,
                          onChanged: (value) {},
                        ),
                      );
                    },
                  ));
                },
              ),
            );
          },
        ),
      ),
    );
  }
}
[✓] Flutter (Channel beta, 1.24.0-10.2.pre, on Mac OS X 10.15.7 19H15 darwin-x64, locale ru-RU)
    • Flutter version 1.24.0-10.2.pre at /Users/boriskarabanov/dev/sdk/flutter
    • Framework revision 022b333a08 (13 days ago), 2020-11-18 11:35:09 -0800
    • Engine revision 07c1eed46b
    • Dart version 2.12.0 (build 2.12.0-29.10.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    • Android SDK at /Users/boriskarabanov/Library/Android/sdk
    • Platform android-30, build-tools 30.0.1
    • ANDROID_HOME = /Users/boriskarabanov/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/boriskarabanov/Library/Android/sdk
    • Java binary at: /Users/boriskarabanov/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.6953283/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.2, Build version 12B45b
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Users/boriskarabanov/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.6953283/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 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.2.4)
    • IntelliJ at /Users/boriskarabanov/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 50.0
    • Dart plugin version 202.8070

[✓] VS Code (version 1.51.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (5 available)
    • Android SDK built for x86 (mobile) • emulator-5554                            • android-x86    • Android 10 (API 29) (emulator)
    • DNS s4502 (mobile)                 • 323c1501ac89e45a8a7d4f96378b819cc7ef3d5c • ios            • iOS 14.2
    • iPhone 12 Pro Max (mobile)         • 7D85263D-F555-47CD-9F9C-F1902DE7F82B     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-2 (simulator)
    • Web Server (web)                   • web-server                               • web-javascript • Flutter Tools
    • Chrome (web)                       • chrome                                   • web-javascript • Google Chrome 87.0.4280.67
    ! Error: DNS s4502 is busy: Copying cache files from device. Xcode will continue when DNS s4502 is finished. (code -10)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsf: focusFocus traversal, gaining or losing focusf: routesNavigator, Router, and related APIs.found in release: 1.24Found to occur in 1.24frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions