Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug report] Request Focus TextFormField not Scroll Correctly #145

Closed
sed1ka opened this issue Sep 15, 2023 · 3 comments
Closed

[Bug report] Request Focus TextFormField not Scroll Correctly #145

sed1ka opened this issue Sep 15, 2023 · 3 comments

Comments

@sed1ka
Copy link

sed1ka commented Sep 15, 2023

Version

6.1.2

Platforms

Android, (untested on iOS)

Device Model

Xiaomi Redmi 9T

flutter info

[√] Flutter (Channel stable, 3.13.3, on Microsoft Windows [Version 10.0.19043.1766], locale en-US)
    • Flutter version 3.13.3 on channel stable at D:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2524052335 (7 days ago), 2023-09-06 14:32:31 -0700
    • Engine revision b8d35810e9
    • Dart version 3.1.1
    • DevTools version 2.25.0

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\Users\septian.andika\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.5.2)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33502.453
    X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop
      development with C++" workload, and include these components:
        MSVC v142 - VS 2019 C++ x64/x86 build tools
         - If there are multiple build tool versions available, install the latest
        C++ CMake tools for Windows
        Windows 10 SDK

[√] Android Studio (version 2022.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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-b2043.56-9586694)

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19043.1766]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 116.0.5845.180
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 116.0.1938.69

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

! Doctor found issues in 1 category.

How to reproduce?

Run my example code I provide

The Bug:
When you tap/request to focus the TextField B the scroll will be reset to the top instead scrolling to the TextField B.
The bug only happen if:

  1. The body in ExtendedNestedScrollView contains more than one TextFormField.
  2. The TextFormField is on bottom of view port. Make sure the TextFormField is covered by the keyboard screen when you press the TextFormField.

Example code (optional)

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

  @override
  State<KrediCashView> createState() => _ExampleViewState();
}

class _ExampleViewState extends State<ExampleView> {
  final FocusNode focusNodeA = FocusNode();
  final FocusNode focusNodeB = FocusNode();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ExtendedNestedScrollView(
        headerSliverBuilder: (_, __) {
          return [
            SliverAppBar(
              title: Text('Bug Focus Node'),
            ),
          ];
        },
        body: SingleChildScrollView(
          child: Column(
            children: [
              const SizedBox(height: 1000),
              TextFormField(
                focusNode: focusNodeA,
                decoration: InputDecoration(
                  labelText: 'TextField A',
                ),
              ),
              const SizedBox(height: 1000),
              TextFormField(
                focusNode: focusNodeB,
                decoration: InputDecoration(
                  labelText: 'TextField B',
                ),
              ),
              const SizedBox(height: 10),
            ],
          ),
        ),
      ),
    );
  }
}
@zmtzawqlp
Copy link
Member

It's better to create an issue for Flutter team first.

@sed1ka
Copy link
Author

sed1ka commented Sep 15, 2023

The bug only happen with the ExtendedNestedScrollView.
Using NestedScrollView with SingleChildScrollView will give result as expected.

It's better to create an issue for Flutter team first.

@sed1ka
Copy link
Author

sed1ka commented Sep 15, 2023

Mysteriously the bug doesn't happen anymore. Even though I haven't made any fix. So I will close the issue

@sed1ka sed1ka closed this as completed Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants