Skip to content

Conversation

@liranzairi
Copy link
Contributor

The color of the TextField's cursor in error state is the same as the error text color by default. However we should be allowed to customize it

Fixes #135580

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Oct 7, 2023
@Renzo-Olivares Renzo-Olivares self-requested a review October 9, 2023 19:34
@Renzo-Olivares
Copy link
Contributor

Renzo-Olivares commented Oct 12, 2023

Hi @lirantzairi, thank you for the contribution!

I think a better place to put cursorErrorColor (or maybe errorCursorColor) might be in InputDecoration and InputDecorationTheme since this is where errorStyle lives and this allows someone to define top level themes in MaterialApp for all their TextFields. What do you think? I do know cursorColor belongs to TextField and DefaultSelectionStyle but i'm leaning towards including this new property on InputDecoration.

/cc @LongCatIsLooong for any thoughts.

@liranzairi
Copy link
Contributor Author

@Renzo-Olivares I was thinking about it, I chose to put it in TextField because the concept of a cursor belongs to TextFields and not to other widgets that use InputDecoration. For example a developer that adds a DropdownButton with InputDecoration might be confused if he sees the option to set a cursor color. It's the same reason why the icon of the dropdown button is managed in the dropdown class and not in the decoration.

Moreover, I would prefer not to connect between cursorErrorColor and errorStyle because I believe that connection was wrong in the first place due to misunderstanding of Material design guidelines.

Lastly, I feel (and this is a wild guess) that this variable is likely to be used by people who set cursorColor, so putting them next to each other is more intuitive.

@Renzo-Olivares
Copy link
Contributor

@lirantzairi I see your point! Thanks for the clear explanation. This PR looks good, my main argument for putting it in InputDecoration or DefaultSelectionStyle is that it would allow the user to override the cursorErrorColor for an entire widget subtree rather than a single TextField. I'm not completely sold on placing it in either (though leaning towards DefaultSelectionStyle), so I think we can hold off on that for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: formatting, put each parameter on their own line and the last parameter should have a trailing comma.

Copy link
Contributor

@Renzo-Olivares Renzo-Olivares left a comment

Choose a reason for hiding this comment

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

Had one small comment but this looks good to me. This will need a secondary reviewer before it is merged, and you need to sync your PR up to master to fix the failing tests.

…35580)

The color of the TextField's cursor in error state is the same as the error text color by default. However we should be allowed to customize it
@liranzairi liranzairi force-pushed the text-field-cursor-color branch from 3ec3499 to 0a0985b Compare October 22, 2023 13:24
@liranzairi
Copy link
Contributor Author

@Renzo-Olivares I fixed the code format according to your comment and rebased on master so that all tests pass now. Thank you for the review :)

@bleroux bleroux self-requested a review October 23, 2023 06:21
Copy link
Contributor

@bleroux bleroux left a comment

Choose a reason for hiding this comment

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

LGTM!

@Renzo-Olivares Renzo-Olivares added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Oct 24, 2023
@auto-submit auto-submit bot merged commit 7cd6fd4 into flutter:master Oct 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 25, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 25, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 25, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 25, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Oct 25, 2023
Roll Flutter from 5e8b5f4 to 5dd2a4e (59 revisions)

flutter/flutter@5e8b5f4...5dd2a4e

2023-10-25 [email protected] Ensure Xcode project is setup to start debugger (flutter/flutter#136977)
2023-10-25 [email protected] Marks Windows build_tests_6_6 to be unflaky (flutter/flutter#137216)
2023-10-25 [email protected] Remove gem and docker files. (flutter/flutter#137200)
2023-10-25 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[gallery] Reland roll gallery to  ecfb9e5352bd12032301b12b30d5853d83d89bda" (flutter/flutter#137264)
2023-10-25 [email protected] [gallery] Reland roll gallery to  ecfb9e5352bd12032301b12b30d5853d83d89bda (flutter/flutter#137199)
2023-10-25 [email protected] Roll Packages from 2faf992 to f751ffb (11 revisions) (flutter/flutter#137254)
2023-10-25 [email protected] Marks Windows build_tests_3_6 to be unflaky (flutter/flutter#137214)
2023-10-25 [email protected] Marks Windows build_tests_5_6 to be unflaky (flutter/flutter#137215)
2023-10-25 [email protected] Marks Windows build_tests_2_6 to be unflaky (flutter/flutter#137213)
2023-10-25 [email protected] Revert "Update `OutlinedButton` tests for Material 3 (#136809)" (flutter/flutter#137242)
2023-10-25 [email protected] Update `OutlinedButton` tests for Material 3 (flutter/flutter#136809)
2023-10-25 [email protected] Let `OverflowBox` be shrink-wrappable (flutter/flutter#129095)
2023-10-25 [email protected] Add dependency on leak_tracker to flutter_test. (flutter/flutter#137069)
2023-10-25 [email protected] fix SliverReorderableLists item wrong offset (flutter/flutter#136828)
2023-10-25 [email protected] Remove `bringup: true` from realm_checker and remove the redundant tool test. (flutter/flutter#137186)
2023-10-25 [email protected] Revert "Fix Gradle lockfiles." (flutter/flutter#137198)
2023-10-24 [email protected] Fix Gradle lockfiles. (flutter/flutter#137190)
2023-10-24 [email protected] Fix Typos (flutter/flutter#137173)
2023-10-24 [email protected] Roll Flutter Engine from d6a48e9963df to 6e09ee14e244 (1 revision) (flutter/flutter#137185)
2023-10-24 [email protected] Roll Flutter Engine from 602b5131ee4d to d6a48e9963df (6 revisions) (flutter/flutter#137180)
2023-10-24 [email protected] TextField - allow to customize cursor color in error state (flutter/flutter#136121)
2023-10-24 [email protected] [macOS] Refactor macOS build/codesize analysis (flutter/flutter#137164)
2023-10-24 [email protected] Roll Flutter Engine from dc00de7dacf4 to 602b5131ee4d (1 revision) (flutter/flutter#137174)
2023-10-24 [email protected] Check the realm file in its own shard. (flutter/flutter#137160)
2023-10-24 [email protected] Roll Flutter Engine from 1890bd7dc412 to dc00de7dacf4 (1 revision) (flutter/flutter#137172)
2023-10-24 [email protected] Roll Flutter Engine from ca7ef01c99c6 to 1890bd7dc412 (2 revisions) (flutter/flutter#137158)
2023-10-24 [email protected] Migrate mac builds to ruby dep. (flutter/flutter#136929)
2023-10-24 [email protected] Roll Packages from 4bf5114 to 2faf992 (7 revisions) (flutter/flutter#137154)
2023-10-24 [email protected] Roll Flutter Engine from 7224835bb65f to ca7ef01c99c6 (1 revision) (flutter/flutter#137153)
2023-10-24 [email protected] fix some typos (flutter/flutter#137144)
2023-10-24 [email protected] Roll Flutter Engine from 8f7488e0b4b5 to 7224835bb65f (1 revision) (flutter/flutter#137150)
2023-10-24 [email protected] Roll Flutter Engine from d58895093d0a to 8f7488e0b4b5 (3 revisions) (flutter/flutter#137135)
2023-10-24 [email protected] Roll Flutter Engine from 2a8471f188cd to d58895093d0a (4 revisions) (flutter/flutter#137130)
2023-10-24 [email protected] Roll Flutter Engine from 71600d89aa3f to 2a8471f188cd (2 revisions) (flutter/flutter#137129)
2023-10-24 [email protected] Roll Flutter Engine from 3dd197dcf9e5 to 71600d89aa3f (1 revision) (flutter/flutter#137127)
2023-10-24 [email protected] Roll Flutter Engine from bdbd1058858b to 3dd197dcf9e5 (2 revisions) (flutter/flutter#137125)
2023-10-24 [email protected] Roll Flutter Engine from 0ef5caa91c40 to bdbd1058858b (1 revision) (flutter/flutter#137119)
2023-10-24 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Use `coverage.collect`'s `coverableLineCache` param to speed up coverage" (flutter/flutter#137121)
2023-10-24 [email protected] Roll Flutter Engine from dd6a6531e816 to 0ef5caa91c40 (1 revision) (flutter/flutter#137114)
2023-10-24 [email protected] Roll Flutter Engine from 0bd703132cc1 to dd6a6531e816 (2 revisions) (flutter/flutter#137111)
2023-10-23 [email protected] Roll Flutter Engine from abeab897a29c to 0bd703132cc1 (3 revisions) (flutter/flutter#137107)
2023-10-23 [email protected] Upgrade packages in flutter and flutter_test. (flutter/flutter#137106)
2023-10-23 49699333+dependabot[bot]@users.noreply.github.com Bump ossf/scorecard-action from 2.2.0 to 2.3.1 (flutter/flutter#137103)
2023-10-23 [email protected] Dartdoc warnings (flutter/flutter#137077)
2023-10-23 [email protected] Roll Flutter Engine from e89f0421bcab to abeab897a29c (5 revisions) (flutter/flutter#137100)
2023-10-23 [email protected] Cover last test/material tests with leak tracking. (flutter/flutter#137004)
...
@tenhobi
Copy link

tenhobi commented Feb 15, 2024

Hi, can I ask you when this PR will be in stable Flutter? Or in general, how can I tell? Thanks a lot!

@MilanVilov
Copy link

Thank you for this PR, I lost almost an hour looking into this issue until I figured it out. Awesome work! 🦾

@liranzairi
Copy link
Contributor Author

Thanks @MilanVilov :)

@gloinho
Copy link

gloinho commented Jul 27, 2024

this works on flutter 3.16.6?

@bleroux
Copy link
Contributor

bleroux commented Jul 28, 2024

this works on flutter 3.16.6?

Not on 3.16, this fix was included in 3.19.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextFormField - when validation fails, cursor color is assigned to be the same as the error text color

6 participants