From c4a2712e8f4d41f4184b4253011c312f42edfca2 Mon Sep 17 00:00:00 2001 From: Bruno Leroux Date: Tue, 2 May 2023 21:34:35 +0200 Subject: [PATCH] Web - Fix selection jump on Chrome for Android (#41202) ## Description This PR fixes cursor jump on Chrome for Android when the user taps in a multiline `TextField`. Using the following code sample:
Code sample ```dart import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( title: 'Text Field Focus', home: MyCustomForm(), ); } } // Define a custom Form widget. class MyCustomForm extends StatelessWidget { const MyCustomForm({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Text Field Focus'), ), backgroundColor: Colors.amber, body: Padding( padding: const EdgeInsets.all(16.0), child: TextField( decoration: const InputDecoration( fillColor: Colors.white, filled: true ), autofocus: true, maxLines: 3, controller: TextEditingController(text: '1\n2\n3\n4\n'), ), ),// This trailing comma makes auto-formatting nicer for build methods. ); } } ```
On a mobile browser, once the page is loaded, tap after the number 3: - Before this PR: the TextField content is automaticaly scrolled and the selection is set after number 1. https://user-images.githubusercontent.com/840911/232051413-b913f890-6cb1-4c60-92d0-7a3bf74cc688.mov ## Implementation A multiline `TextField` relies on an HTML `