Skip to content

TextField and TextFormField in SliverMainAxisGroup scroll the screen up when in focus #141577

@meg4cyberc4t

Description

@meg4cyberc4t

Steps to reproduce

  1. Create a Custom ScrollView and put a TextField in it at such a distance that you need to scroll the screen down to it.
  2. Click, highlight, or change something inside the TextField

Expected results

Changing data inside a textfield

Actual results

Changing data inside a textfield + screen will scroll up on every change

Code sample

Code sample
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: [
          SliverMainAxisGroup(
            slivers: [
              SliverToBoxAdapter(
                child: Container(
                  color: Colors.blue,
                  height: 500,
                ),
              ),
              SliverToBoxAdapter(
                child: Container(
                  color: Colors.red,
                  height: 500,
                ),
              ),
              const SliverToBoxAdapter(child: TextField()),
              SliverToBoxAdapter(
                child: Container(
                  color: Colors.green,
                  height: 500,
                ),
              ),
            ],
          )
        ],
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
2024-01-15.19.05.18.mov

Logs

No response

Flutter Doctor output

Doctor output
molchanovia@Air-Igor Projects % flutter doctor -v


[✓] Flutter (Channel stable, 3.16.7, on macOS 14.2.1 23C71 darwin-arm64, locale
    ru-RU)
    • Flutter version 3.16.7 on channel stable at
      /opt/homebrew/Caskroom/flutter/3.13.8/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ef1af02aea (4 days ago), 2024-01-11 15:19:26 -0600
    • Engine revision 4a585b7929
    • Dart version 3.2.4
    • DevTools version 2.28.5

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/molchanovia/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.13.0

[✓] Android Studio (version 2022.3)
    • 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
      17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.83.1)
    • VS Code at /Users/molchanovia/Downloads/Visual Studio Code 2.app/Contents
    • Flutter extension version 3.81.20231227

[✓] VS Code (version 1.83.1)
    • VS Code at /Users/molchanovia/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.81.20231227

[✓] Connected device (1 available)
    • iPhone 15 (mobile) • 99881AD8-A92E-4FFF-B463-BFCA1D46274C • ios •
      com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)

[✓] Network resources
    • All expected network resources are available.

• 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: scrollingViewports, list views, slivers, etc.found in release: 3.16Found to occur in 3.16found in release: 3.19Found to occur in 3.19frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions