Skip to content

Conversation

@GaryQian
Copy link
Contributor

@GaryQian GaryQian commented Apr 26, 2019

Description

This vertically centers the caret over the text and removes the constant vertical position offset, which was causing the caret to be at a bad height (too high) especially for small fonts.

After this PR lands, the remaining issues regarding caret primarily deal with determining what to set the height to. This change should bring it to a strictly better and reasonable state for both iOS and Android, but may not quite replicate the exact platform behavior.

Related Issues

#31661

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@GaryQian GaryQian added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. labels Apr 26, 2019
@GaryQian GaryQian self-assigned this Apr 26, 2019
@GaryQian GaryQian added the platform-ios iOS applications specifically label Apr 26, 2019
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a switch

@dnfield
Copy link
Contributor

dnfield commented Apr 26, 2019

Tests? Maybe a golden?

GaryQian added a commit to flutter/goldens that referenced this pull request Apr 26, 2019
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@xster
Copy link
Member

xster commented Apr 27, 2019

Unfortunately we haven't added a golden from #27851 yet. Could you add a golden test on the CupertinoTextField and TextField for the caret?

GaryQian added a commit to flutter/goldens that referenced this pull request Apr 27, 2019
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for sake of the PR title, if you're changing iOS and non-iOS behavior, remove the iOS part from the description (if I understood correctly)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a value that is added here and then subtracted later, this just removes the redundant math for android

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit hard to read. Maybe make it a local variable with a self-documenting name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be meaningful since we'll never call updateFloatingCursor on Android

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I can remove this then, to prevent any unnecessary pain in future breakages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd want to put the thing you want to golden test against in a repaintboundary. Otherwise you end up with a really big image like https://github.com/flutter/goldens/blob/master/packages/flutter/test/cupertino/text_field_cursor_test.0.0.png.

You'd also want to isolate it from things like the debug banner etc that aren't specifically the scenario you're trying to test.

GaryQian added a commit to flutter/goldens that referenced this pull request Apr 29, 2019
@xster
Copy link
Member

xster commented Apr 29, 2019

I tested the branch a bit locally. It seems like on CupertinoTextField, this introduces a small vertical shift in the text when dragging the selection handle.

https://streamable.com/d0nia

We should resolve it before merging.

@GaryQian
Copy link
Contributor Author

Have confirmed that the jitter is not due to this patch. It repros on iPhone XR on master. May have to do with an unintended side effect of a21a1f4?

@GaryQian GaryQian merged commit 4102486 into flutter:master May 1, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
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 framework flutter/packages/flutter repository. See also f: labels. platform-ios iOS applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants