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

[iOS] Hold and drag spacebar does not move cursor when obscureText is true. #122139

Closed
daniloapr opened this issue Mar 7, 2023 · 10 comments · Fixed by flutter/engine#40216 or #122383
Closed
Labels
a: text input Entering text in a text field or keyboard related problems c: new feature Nothing broken; request for a new capability found in release: 3.7 Found to occur in 3.7 found in release: 3.9 Found to occur in 3.9 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P3 Issues that are less important to the Flutter project platform-ios iOS applications specifically r: fixed Issue is closed as already fixed in a newer version

Comments

@daniloapr
Copy link
Contributor

Steps to Reproduce

  1. Create a new application with a TextFormField or TextField and set obscureText to true as in the Code Sample below
  2. Run the application on an iOS device or simulator
  3. Long press on the keybord's spacebar and try to move the cursor

Expected results:
Should be possible to move the cursor using the spacebar

Actual results:

  • When obscureText is true before the TextField is focused, the cursor does not move
  • When obscureText is false before the TextField is focused, the cursor moves as expected
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(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

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

class _MyHomePageState extends State<MyHomePage> {
  final _controller = TextEditingController();
  bool _obscureText = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Flutter Demo')),
      body: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 20),
        child: Column(
          children: [
            const SizedBox(height: 80),
            TextFormField(
              controller: _controller,
              obscureText: _obscureText,
              decoration: InputDecoration(
                suffixIcon: IconButton(
                  icon: Icon(
                    _obscureText ? Icons.visibility_off : Icons.visibility,
                  ),
                  onPressed: () {
                    setState(() {
                      _obscureText = !_obscureText;
                    });
                  },
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
Logs
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.5, on macOS 13.2.1 22D68 darwin-arm64, locale
    en-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.76.0)
[✓] Connected device (5 available)
[✓] HTTP Host Availability

• No issues found!
screen-recording-2023-03-07-at-184801_WuxJXMV7.mp4
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Mar 8, 2023
@darshankawar
Copy link
Member

Thanks for the report. Using code sample, I was able to replicate the reported behavior on latest versions.

stable, master flutter doctor -v
[!] Flutter (Channel stable, 3.7.5, on macOS 12.2.1 21D62 darwin-x64, locale
    en-GB)
    • Flutter version 3.7.5 on channel stable at
      /Users/dhs/documents/fluttersdk/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/dhs/documents/fluttersdk/flutter. Consider adding
      /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
      Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
      of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c07f788888 (7 days ago), 2023-02-22 17:52:33 -0600
    • Engine revision 0f359063c4
    • Dart version 2.19.2
    • DevTools version 2.20.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.

[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

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

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

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

[!] Flutter (Channel master, 3.9.0-1.0.pre.92, on macOS 12.2.1 21D62 darwin-x64,
    locale en-GB)
    • Flutter version 3.9.0-1.0.pre.92 on channel master at
      /Users/dhs/documents/fluttersdk/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/dhs/documents/fluttersdk/flutter. Consider adding
      /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
      Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
      of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5a279edc23 (3 hours ago), 2023-03-07 21:24:23 -0500
    • Engine revision 694a14ca6e
    • Dart version 3.0.0 (build 3.0.0-308.0.dev)
    • DevTools version 2.22.2
    • 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 30.0.3)
    • Android SDK at /Users/dhs/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for
      more details.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13C100
    • CocoaPods version 1.11.2

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

[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 65.1.4
    • Dart plugin version 213.7228

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

[✓] Connected device (3 available)
    • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios
      • iOS 15.3.1 19D52
    • macOS (desktop)           • macos                                    •
      darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)              • chrome                                   •
      web-javascript • Google Chrome 109.0.5414.119

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

! Doctor found issues in 1 category.
      
[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

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

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

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.



@darshankawar darshankawar added a: text input Entering text in a text field or keyboard related problems platform-ios iOS applications specifically has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.7 Found to occur in 3.7 found in release: 3.9 Found to occur in 3.9 framework flutter/packages/flutter repository. See also f: labels. and removed in triage Presently being triaged by the triage team labels Mar 8, 2023
@hellohuanlin hellohuanlin added c: new feature Nothing broken; request for a new capability P3 Issues that are less important to the Flutter project labels Mar 8, 2023
@justinmc
Copy link
Contributor

justinmc commented Mar 9, 2023

CC @Renzo-Olivares from triage. Maybe we just have floating cursor disabled explicitly when obscureText is true for some reason?

@daniloapr
Copy link
Contributor Author

@justinmc I thought about that too, but it should be re-enabled when the state changes to obscureText: false.

@justinmc
Copy link
Contributor

This doesn't seem to work on native iOS if I'm not mistaken? CC @Renzo-Olivares. If I try to use floating cursor (hold and drag spacebar) in a native password field, it doesn't work for me (simulator).

Does anyone see differently?

@Renzo-Olivares
Copy link
Contributor

Renzo-Olivares commented Mar 23, 2023

I'm seeing this on the simulator (works on non obscured/ does not work on obscured):

Screen.Recording.2023-03-23.at.4.52.19.PM.mov

@rakeshparveen5

This comment was marked as duplicate.

@justinmc
Copy link
Contributor

justinmc commented Apr 6, 2023

Alright since this doesn't even work on native, it will be low priority for Flutter to support it. But if we could without too much overhead, why not? I say keep this issue open in case anyone is inspired and wants to implement this.

@erindolson
Copy link

@justinmc I think that there might be a misunderstanding here. (It's possible it's on my side).

Actual results:

  • When obscureText is true before the TextField is focused, the cursor does not move
  • When obscureText is false before the TextField is focused, the cursor moves as expected

Emphasis on "before the TextField is focused".

Note how on 0:53 of the video, though obscureText=true, you can scroll through the text because daniloapr unobscured the text before focusing on the text box.

I think it makes sense to match the iOS behavior and not have the spacebar hold move the cursor when the text is obscured, but when you press the unobscure button I'd expect the spacebar hold to move the cursor.

Current behavior:
Text obscured before focusing -> spacebar hold won't move cursor
Text unobscured while text box is in focus -> spacebar hold won't move cursor
User taps off text box to unfocus
User refocuses -> spacebar hold WILL move cursor

That still seems like a bug to me.

I'd expect:
Text obscured before focusing -> spacebar hold won't move cursor
Text unobscured while text box is in focus -> spacebar hold will move cursor

@justinmc
Copy link
Contributor

Ah sorry about that, you're right now that I look more closely. Switching between obscured and unobscured should disabled and enabled the floating cursor.

This likely is due to the engine not being informed of the change between obscured and not. This actually came up recently in one or two places (#122300). I think when that is fixed, this issue should be fixed as well.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: text input Entering text in a text field or keyboard related problems c: new feature Nothing broken; request for a new capability found in release: 3.7 Found to occur in 3.7 found in release: 3.9 Found to occur in 3.9 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P3 Issues that are less important to the Flutter project platform-ios iOS applications specifically r: fixed Issue is closed as already fixed in a newer version
Projects
None yet
7 participants