Skip to content

CupertinoTextField autocorrect highlight vertically misaligned #150813

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

Open
justinmc opened this issue Jun 26, 2024 · 4 comments
Open

CupertinoTextField autocorrect highlight vertically misaligned #150813

justinmc opened this issue Jun 26, 2024 · 4 comments
Labels
P2 Important issues not at the top of the work list platform-ios iOS applications specifically team-text-input Owned by Text Input team triaged-text-input Triaged by Text Input team

Comments

@justinmc
Copy link
Contributor

justinmc commented Jun 26, 2024

Steps to reproduce

  1. Run any app with a CupertinoTextField, such as the one below.
  2. Type some text into the field and until autocorrect highlights it. If you can't trigger it, try a commonly misspelled word.

Expected results

The text, cursor, and highlight are all aligned and fully covered.

Actual results

The highlight appears to be too high. The text is not centered, and the cursor hangs below the highlight.

Code sample

Code sample
import 'package:flutter/cupertino.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(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: const <Widget>[
            Padding(
              padding: EdgeInsets.symmetric(horizontal: 32.0),
              child: CupertinoTextField(),
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

ios_big
More pictures

Flutter on iOS (unscaled)

Screenshot 2024-06-25 at 5 07 56 PM

Some other platforms

selection_alignment

Logs

No response

Flutter Doctor output

Doctor output
[!] Flutter (Channel master, 3.23.0-13.0.pre.335, on macOS 14.5 23F79 darwin-arm64, locale en)
    ! Unknown upstream repository.
      Reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[!] Android Studio (version unknown)
    ✗ Unable to determine Android Studio version.
[✓] Android Studio (version 2023.2)
[✓] Connected device (3 available)
    ! Error: Browsing on the local area network for Bella’s iPad. 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

! Doctor found issues in 2 categories.

Reproduced on an iOS 17.4 simulator.

@justinmc justinmc added platform-ios iOS applications specifically team-text-input Owned by Text Input team labels Jun 26, 2024
@justinmc
Copy link
Contributor Author

It was suggested that #150770 might be a culprit, but if I revert it locally I can still reproduce the bug.

@justinmc
Copy link
Contributor Author

Possibly related: #150813 #137666

@justinmc justinmc changed the title CupertinoTextField selection vertically misaligned CupertinoTextField autocorrect highlight vertically misaligned Jun 26, 2024
@justinmc justinmc added triaged-text-input Triaged by Text Input team fyi-ios For the attention of iOS platform team P2 Important issues not at the top of the work list labels Jun 27, 2024
@justinmc
Copy link
Contributor Author

Talking to @LongCatIsLooong about this in triage, this autocorrect highlight is drawn by iOS. We send the bounding box of the text to iOS.

FYI @hellohuanlin in case you have any thoughts here. I think the framework is just sending the bounding box of the text, not sure why it would be slightly off here. See also #150815.

@hellohuanlin
Copy link
Contributor

hellohuanlin commented Jun 27, 2024

I'm curious is the offset amount proportional to font size? or is it the same offset for all font sizes?

As a last resort workaround, maybe try moving FlutterTextInputView a bit lower? IIRC the highlight should move with it.

@hellohuanlin hellohuanlin added the triaged-ios Triaged by iOS platform team label Jul 17, 2024
@flutter-triage-bot flutter-triage-bot bot removed fyi-ios For the attention of iOS platform team triaged-ios Triaged by iOS platform team labels Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Important issues not at the top of the work list platform-ios iOS applications specifically team-text-input Owned by Text Input team triaged-text-input Triaged by Text Input team
Projects
None yet
Development

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy