Repository: flutter
Issue: [iOS] Keyboard loses focus after Look Up text selection
Labels: a: text input,platform-ios,framework,engine,has reproducible steps,P2,team-ios,triaged-ios,found in release: 3.19,found in release: 3.20,fyi-text-input

### Steps to reproduce

App is launched on iOS 17.2 (reproduces both on a simulator and on a real device)

1. Select text in Text Field
2. Press Look up
3. Close the Look up dialog

### Expected results

Keyboard hides or text field returns its focus

### Actual results

Keyboard persists on screen, but the text field does not retain focus and keyboard does not hide via `unfocus()` (see video)

### Code sample

<details open><summary>Code sample</summary>

```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 MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        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(
      appBar: AppBar(),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const TextField(),
            TextButton(
              onPressed: () => FocusScope.of(context).unfocus(),
              child: const Text('FocusScope.of(context).unfocus()'),
            ),
            TextButton(
              onPressed: () => FocusManager.instance.primaryFocus?.unfocus(),
              child:
                  const Text('FocusManager.instance.primaryFocus?.unfocus()'),
            ),
          ],
        ),
      ),
    );
  }
}


```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

https://github.com/flutter/flutter/assets/6888015/d2470686-152c-4f3b-8476-66763d7a7932

</details>


### Logs

<details open><summary>Logs</summary>

```console
no logs
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[flutter] flutter doctor -v
[!] Flutter (Channel stable, 3.19.2, on macOS 14.3.1 23D60 darwin-arm64, locale ru-RU)
    • Flutter version 3.19.2 on channel stable at /Users/viktorstarikov/fvm/versions/3.19.2
    ! Warning: `flutter` on your path resolves to /Users/viktorstarikov/fvm/versions/3.10.4/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/viktorstarikov/fvm/versions/3.19.2. Consider adding /Users/viktorstarikov/fvm/versions/3.19.2/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.0.1/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/viktorstarikov/fvm/versions/3.19.2. Consider adding /Users/viktorstarikov/fvm/versions/3.19.2/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7482962148 (2 days ago), 2024-02-27 16:51:22 -0500
    • Engine revision 04817c99c9
    • Dart version 3.3.0
    • DevTools version 2.31.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/viktorstarikov/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode-15.2.0.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.13.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • 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.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.86.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.82.0

[✓] Connected device (5 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        • android-arm64  • Android 13 (API 33) (emulator)
    • iPhone 6s Plus (mobile)     • 00008110-000A388A3AF9801E            • ios            • iOS 17.2.1 21C66
    • iPhone 15 Pro Max (mobile)  • 97CAF3A4-246E-462F-968B-A414DE0A3445 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator)
    • macOS (desktop)             • macos                                • darwin-arm64   • macOS 14.3.1 23D60 darwin-arm64
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 122.0.6261.94
    ! Error: Browsing on the local area network for Apple Watch — Viktor. Ensure the device is unlocked and discoverable via Bluetooth. (code -27)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

```

</details>