Skip to content

TextField inputAction changes do not get applied while TextField is focused #185466

Open

Description

@jaanus

Steps to reproduce

  1. Have some Flutter code that changes textInputAction of a TextField at runtime while a TextField is focused and the keyboard is up
  2. Do something that changes textInputAction value

Expected results

iOS keyboard action button style should change to match the new value

Actual results

iOS keyboard action button style does not change while the TextField remains in focus

Code sample

Code sample

The bug is probably a duplicate of #97253 on a low level, but I am using a higher level API, so I decided to submit a new issue with a different repro.

import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: TextInputActionReproPage());
  }
}

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

  @override
  State<TextInputActionReproPage> createState() =>
      _TextInputActionReproPageState();
}

class _TextInputActionReproPageState extends State<TextInputActionReproPage> {
  final _controller = TextEditingController();
  final _focusNode = FocusNode();

  String _lastSubmittedValue = '(none)';

  @override
  void dispose() {
    _controller.dispose();
    _focusNode.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final hasText = _controller.text.trim().isNotEmpty;

    // This is correctly recomputed during each build, but changes are not
    // applied to native iOS keyboard until the text field unfocuses.
    final requestedAction = hasText
        ? TextInputAction.send
        : TextInputAction.done;

    return Scaffold(
      appBar: AppBar(title: const Text('TextInputAction Repro')),
      body: SafeArea(
        child: Padding(
          padding: const EdgeInsets.all(24),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              Text(
                'Requested textInputAction:',
                style: Theme.of(context).textTheme.titleMedium,
              ),
              const SizedBox(height: 8),
              Text(
                requestedAction.toString(),
                style: Theme.of(context).textTheme.headlineSmall,
              ),
              const SizedBox(height: 24),
              TextField(
                controller: _controller,
                focusNode: _focusNode,
                autofocus: true,
                decoration: const InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: 'Type here, then clear the field',
                ),
                // THIS IS THE BUG: when requestedAction changes, iOS keyboard action
                // does not change until the field is unfocused and refocused.
                textInputAction: requestedAction,
                onChanged: (_) => setState(() {}),
                onSubmitted: (value) {
                  setState(() {
                    _lastSubmittedValue = value;
                  });
                },
              ),
              const SizedBox(height: 16),
              FilledButton(
                onPressed: () {
                  _controller.clear();
                  setState(() {});
                  _focusNode.requestFocus();
                },
                child: const Text('Clear and keep focus'),
              ),
              const SizedBox(height: 24),
              Text('Last submitted value: $_lastSubmittedValue'),
              const Spacer(),
              const Text(
                'On iOS, the label above changes between done and send as the '
                'text changes, but the keyboard return key does not update '
                'until the text input connection is recreated.',
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-04-23.11.15.23.mp4

Logs

Logs

n/a

Flutter Doctor output

Doctor output
jaanus@jk-mbp ~/D/F/text_input_action_mre> flutter doctor -v
[✓] Flutter (Channel stable, 3.38.1, on macOS 26.4.1 25E253 darwin-arm64, locale et-EE) [1 132ms]
    • Flutter version 3.38.1 on channel stable at /Users/jaanus/fvm/versions/3.38.1
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b45fa18946 (5 months ago), 2025-11-12 22:09:06 -0600
    • Engine revision b5990e5ccc
    • Dart version 3.10.0
    • DevTools version 2.51.1
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios,
      no-cli-animations, enable-native-assets, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [2,7s]
    • Android SDK at /Users/jaanus/Library/Android/sdk
    • Emulator version 36.1.9.0 (build_id 13823996) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • ANDROID_HOME = /Users/jaanus/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.7+-13880790-b1038.58)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.3) [2,6s]
    • Xcode at /Applications/Xcode-26.3.app/Contents/Developer
    • Build 17C529
    • CocoaPods version 1.16.2

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

[✓] Connected device (4 available) [7,5s]
    • Pixel 6 (mobile)       • 21101FDF60088E                       • android-arm64  • Android 16 (API 36)
    • iPhone 17 Pro (mobile) • 4B67BFD5-3197-4042-A7D4-2854280598F7 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-26-3
      (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 26.4.1 25E253 darwin-arm64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 147.0.7727.102
    ! Error: Browsing on the local area network for JK iPhone 15 Pro. Ensure the device is unlocked and attached with a cable or
      associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for JK iPhone 17 Pro. Ensure the device is unlocked and attached with a cable or
      associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for Ultra 2. Ensure the device is unlocked and discoverable via Bluetooth. (code
      -27)
    ! Error: Browsing on the local area network for 15. Ensure the device is unlocked and attached with a cable or associated with
      the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

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

• No issues found!

Activity

  1. added
    in triage
    a: text input
    platform-ios
    has reproducible steps
    fyi-ios
    team-text-input
    and removed
    in triage
    on Apr 23, 2026
  2. mbcorona commented on Apr 23, 2026

    @mbcorona
    Member

    Hi @jaanus , thank you for the detailed report and for including a code sample that reproduces the issue.
    Reproducible on Flutter 3.41.7
    Routing to team-text-input for investigation.

  3. justinmc commented on Apr 23, 2026

    @justinmc
    Contributor

    @mbcorona Are you able to reproduce this on any platform other than iOS? @LongCatIsLooong had a hunch that this was due to the framework not sending updates to the platform.

  4. added
    P2
    triaged-framework
    on Apr 23, 2026
  5. mbcorona commented on Apr 23, 2026

    @mbcorona
    Member

    @justinmc I was able to replicate also on Android simulator, sharing video findings:

    Screen.Recording.2026-04-23.at.2.43.58.PM.mov

    And adding platform-android

  6. added
    platform-android
    on Apr 23, 2026
  7. added
    triaged-ios
    on Apr 23, 2026
  8. LongCatIsLooong commented on Apr 23, 2026

    @LongCatIsLooong
    Contributor

    Removing fyi-ios: this is likely because the framework does not call updateConfig when input action changes: https://github.com/flutter/flutter/blob/main/packages/flutter/lib/src/widgets/editable_text.dart

  9. removed
    triaged-ios
    fyi-ios
    on Apr 23, 2026
  10. changed the title [-]TextField inputAction changes do not get applied on iOS while TextField is focused[/-] [+]TextField inputAction changes do not get applied while TextField is focused[/+] on Apr 23, 2026
  11. Istiak-Ahmed78 commented on Apr 25, 2026

    @Istiak-Ahmed78
    Contributor

    I was able to reproduce the issue on my Android Device and noticed a consistent pattern:

    • Initially, the text field is empty and the keyboard is not visible. When I tap on the field, the keyboard appears with the “Done” action.
    • After typing something, the label at the top updates to “TextInputAction.send”, but the keyboard still shows the “Done” button.
    • When I press the “Done” button, the keyboard disappears. Upon refocusing the text field, the keyboard reappears—this time with the correct “Send” action.
    • However, this correction does not occur if I dismiss the keyboard using the back button. In that case, when I tap the text field again, the keyboard still shows the incorrect “Done” action.
    • If I clear the text using the “clear and keep focus” button, the text is removed but the keyboard continues to show the “Send” action.
    • Pressing the “Send” button dismisses the keyboard. When I tap the text field again, the keyboard reverts to the “Done” action.

    The keyboard action button does not update in real time. It only corrects itself after pressing the (incorrect) action button and refocusing the text field. However, this correction does not happen when dismissing the keyboard via the back button or by tapping outside the field.

  12. Istiak-Ahmed78 commented on Apr 25, 2026

    @Istiak-Ahmed78
    Contributor

    Removing fyi-ios: this is likely because the framework does not call updateConfig when input action changes: https://github.com/flutter/flutter/blob/main/packages/flutter/lib/src/widgets/editable_text.dart

    previously it would update the config only if obscureText , keyboardType updates.
    // Code before this fix

     final obscureTextChanged = oldWidget.obscureText != widget.obscureText;
          if (obscureTextChanged || oldWidget.keyboardType != widget.keyboardType) {
            if (obscureTextChanged) {
              // When obscureText is toggled, we should reset its state to prevent the last character from being visible between state changes.
              _obscureShowCharTicksPending = 0;
              _obscureLatestCharIndex = null;
            }
            _textInputConnection!.updateConfig(_effectiveAutofillClient.textInputConfiguration);
          }

    I added another check: textInputActionChanged = oldWidget.textInputAction != widget.textInputAction;.

          final obscureTextChanged = oldWidget.obscureText != widget.obscureText;
          final keyboardTypeChanged = oldWidget.keyboardType != widget.keyboardType;
          final textInputActionChanged = oldWidget.textInputAction != widget.textInputAction;
    
          if (obscureTextChanged || keyboardTypeChanged || textInputActionChanged) {
            if (obscureTextChanged) {
              // When obscureText is toggled, we should reset its state to prevent the last character from being visible between state changes.
              _obscureShowCharTicksPending = 0;
              _obscureLatestCharIndex = null;
            }
              _textInputConnection!.updateConfig(_effectiveAutofillClient.textInputConfiguration);
         
          }

    But unfortunately this also did not help. even though the textInputActionChanged was detected, updateConfig was being called but the action button on the keyboard UI doesnot get updated. However, restarting the connection resolved the issue when textInputActionChanged detected

     // If textInputAction changed, restart the connection to force IME refresh
            if (textInputActionChanged) {
              _scheduleRestartConnection(); // Now the keyboard action button updates in real-time
            } else {
              _textInputConnection!.updateConfig(_effectiveAutofillClient.textInputConfiguration);
            }

    Lets discuss further in the PR #185582

  13. removed
    triaged-framework
    on Apr 25, 2026
  14. flutter-triage-bot commented on Apr 25, 2026

    @flutter-triage-bot

    The triaged-framework label is irrelevant if there is no team-framework label or fyi-framework label.

  15. added
    ⏳
    on Aug 31, 2026
  16. flutter-triage-bot commented on Aug 31, 2026

    @flutter-triage-bot

    This issue is assigned to @Istiak-Ahmed78 but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

  17. added
    triaged-text-input
    on Oct 1, 2026
  18. removed
    ⏳
    on Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2a: text inputhas reproducible stepsplatform-androidplatform-iosteam-text-inputtriaged-text-input

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions