Skip to content

Web: Cursor jumps to the start, if TextField (with Autofill) changes size or transform #63596

@nilsreichardt

Description

@nilsreichardt

Description

TextfieldBug

If an TextField with the autofill parameter (this is important) gets an error from a StreamBuilder / FutureBuilder the cursor goes to the start of the TextField and it isn't possible to type anything new.

Steps to Reproduce

Code to reproduce
import 'dart:math';

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  Future<int> throwExecptionAfter3Seconds() async {
    await Future.delayed(const Duration(seconds: 3));
    throw Random().nextInt(1000);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Demo',
      home: Material(
        child: Padding(
          padding: const EdgeInsets.all(32),
          child: Center(
            child: FutureBuilder<void>(
              future: throwExecptionAfter3Seconds(),
              builder: (context, snapshot) {
                return TextField(
                  autofillHints: [AutofillHints.email], // Bug works only with this line!
                  decoration:
                      InputDecoration(errorText: snapshot.error?.toString()),
                );
              },
            ),
          ),
        ),
      ),
    );
  }
}

  1. Run code.
  2. Type something before the error (from FutureBuilder) is thrown --> error will be thrown after 3 seconds.
  3. See that cursor at the beginning and typing isn't possible anymore.

Flutter doctor

Flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.21.0-10.0.pre.55, on Mac OS X 10.15.5 19F101,
    locale en-DE)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.47.3)
 
[✓] Connected device (4 available)            
    ! Error: iPhone von Roland is not connected. Xcode will continue when iPhone
      von Roland is connected. (code -13)

• No issues found!

cc: @nturgut @LongCatIsLooong

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projecta: text inputEntering text in a text field or keyboard related problemsfound in release: 1.21Found to occur in 1.21platform-webWeb applications specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions