Skip to content

TextEditingValue selection bug #129272

@subzero911

Description

@subzero911

Is there an existing issue for this?

Steps to reproduce

  1. Create a TextFormField.
  2. Add TextController.
  3. Add a custom button with GestureDetector above the TextFormField via Stack.
  4. onTap: () => _textController.text = '';
  5. TextFormField is cleared.
  6. Try to input some text

Expected results

You can input the text.

Actual results

Focus is still on the TextFormField, but input no longer works, until I tap to the TextFormField once more.

It works though if I change to _textController.clear();

The reason behind is https://api.flutter.dev/flutter/services/TextEditingValue/TextEditingValue.html
Selection remains the same, while text now is empty string and length is 0.

Code sample

image

OutlinedLabeledTextField code fragment:

           Stack(
            children: [
              TextFormField(
                controller: widget.textController,
                enabled: !widget.isLocked,
                initialValue: widget.initialValue,
                textCapitalization: widget.textCapitalization,
                inputFormatters: widget.inputFormatters,
                keyboardType: widget.keyboardType,
                textInputAction: widget.textInputAction,
                onChanged: widget.onChanged,
                onFieldSubmitted: widget.onSubmitted,
                maxLines: widget.maxLines,
                ),
              ),
              SizedBox(
                height: 44,
                child: Align(
                  alignment: Alignment.centerRight,
                  child: Builder(
                    builder: (context) {
                      if (widget.hasEraseButton) {
                        return Padding(
                          padding: const EdgeInsets.only(right: 12),
                          child: GestureDetector(
                            onTap: widget.onErase,
                            child: Assets.icons.clearFill.svg(package: Strings.packageName),
                          ),
                        );
                      }
                      return const SizedBox.shrink();
                    },
                  ),
                ),
              ),
            ],
          ),

Screenshots or Video

video_2023-06-21_16-13-17.mp4

Logs

?

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.10.5, on macOS 13.0.1 22A400 darwin-arm64, locale ru-RU)
    • Flutter version 3.10.5 on channel stable at /opt/homebrew/Caskroom/flutter/3.3.10/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 796c8ef792 (8 days ago), 2023-06-13 15:51:02 -0700
    • Engine revision 45f6e00911
    • Dart version 3.0.5
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/svmolchan1/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.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 11.0.13+0-b1751.21-8125866)

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

[✓] Connected device (3 available)
    • M2101K9AG (mobile) • cc706425 • android-arm64  • Android 13 (API 33)
    • macOS (desktop)    • macos    • darwin-arm64   • macOS 13.0.1 22A400 darwin-arm64
    • Chrome (web)       • chrome   • web-javascript • Google Chrome 109.0.5414.119

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

• No issues found!

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsd: api docsIssues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.r: 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