-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Update documentation to discourage using the TextEditingController.text setter #146151
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
Update documentation to discourage using the TextEditingController.text setter #146151
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some quick comments. I'll read over the issue thread again when I have a chance to refresh myself on this bug, but I left a general request for more details for now.
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think with the changes below, it still makes sense to merge this PR, even though the original bug is not reproducible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. But I think the text setter documentation should be more strongly worded to discourage people from using it (so you could just say that don't use this setter, unless you're writing a test or something).
Maybe adding the @visibleForTesting annotation will keep people from using this in real-world apps?
| /// [TextEditingController]; **however, one should not also set [selection] | ||
| /// in a separate statement. To change both the [text] and the [selection] | ||
| /// change the controller's [value].** | ||
| /// change the controller's [value].** Setting this here will clear |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think most readers will interpret "clear" as "setting the current selection and composing range both to (0, 0)" but the selection range will actually be set to (-1, -1) which usually isn't what people wanted or expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we say -1,-1 instead of "clear" it's probably even more confusing, because it's actually immediately changed to 0,0 by the engine. Or providing a full explanation of this here might be too daunting, and it's an implementation detail we'd have to update later if we change it. I think the best option is "clear" unless someone comes up with another idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe invalidate? Though I can see how that might be confusing too.
|
Maybe to make it more strongly worded add: "so avoid using it directly unless that is the desired behavior." |
|
LGTM w/ small comment. |
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
|
could you try adding |
Roll Flutter from ac2ca93 to 477ebd8 (32 revisions) flutter/flutter@ac2ca93...477ebd8 2024-04-05 [email protected] Roll Flutter Engine from 95ffe73ac2a8 to 6974dbac35a1 (2 revisions) (flutter/flutter#146350) 2024-04-05 [email protected] Roll pub packages (flutter/flutter#146348) 2024-04-05 [email protected] Roll Packages from dce6f0c to 764d997 (4 revisions) (flutter/flutter#146344) 2024-04-05 [email protected] Roll Flutter Engine from 292c48b9af5e to 95ffe73ac2a8 (1 revision) (flutter/flutter#146343) 2024-04-05 [email protected] Roll pub packages (flutter/flutter#146331) 2024-04-05 [email protected] Roll Flutter Engine from 23a1d0d2fce6 to 292c48b9af5e (1 revision) (flutter/flutter#146330) 2024-04-05 [email protected] Roll Flutter Engine from 597d33f57183 to 23a1d0d2fce6 (1 revision) (flutter/flutter#146327) 2024-04-05 [email protected] Roll Flutter Engine from 1fa0623bb07f to 597d33f57183 (1 revision) (flutter/flutter#146325) 2024-04-05 [email protected] Roll Flutter Engine from f17d586de6f1 to 1fa0623bb07f (1 revision) (flutter/flutter#146324) 2024-04-05 [email protected] Roll Flutter Engine from d44462a42d73 to f17d586de6f1 (4 revisions) (flutter/flutter#146322) 2024-04-05 [email protected] Fix cursor is not centered when cursorHeight is set (non-Apple platforms). (flutter/flutter#145829) 2024-04-05 [email protected] refactor: Perform plugin resolution per platform (flutter/flutter#144506) 2024-04-04 [email protected] `ExpansionTile` Unable to remove right padding from title (flutter/flutter#145271) 2024-04-04 [email protected] Roll Flutter Engine from dcc99d652154 to d44462a42d73 (1 revision) (flutter/flutter#146311) 2024-04-04 49699333+dependabot[bot]@users.noreply.github.com Bump codecov/codecov-action from 4.1.1 to 4.2.0 (flutter/flutter#146310) 2024-04-04 [email protected] Roll Flutter Engine from e3104af94328 to dcc99d652154 (4 revisions) (flutter/flutter#146308) 2024-04-04 [email protected] Roll Flutter Engine from fa4d97e363ff to e3104af94328 (2 revisions) (flutter/flutter#146300) 2024-04-04 [email protected] Remove dead `compareIosVersions` function (flutter/flutter#146298) 2024-04-04 [email protected] Adds semanticsLabel to MenuItemButton (flutter/flutter#145846) 2024-04-04 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Bump to AGP 8.1/Gradle 8.3 (almost) everywhere (#146181)" (flutter/flutter#146305) 2024-04-04 [email protected] Roll Flutter Engine from 918c72b803cc to fa4d97e363ff (2 revisions) (flutter/flutter#146299) 2024-04-04 [email protected] Bump to AGP 8.1/Gradle 8.3 (almost) everywhere (flutter/flutter#146181) 2024-04-04 [email protected] Roll Flutter Engine from 03cd54d4285a to 918c72b803cc (2 revisions) (flutter/flutter#146296) 2024-04-04 [email protected] Fix InputDecorator suffix and prefix IconButtons ignore `IconButtonTheme` (flutter/flutter#145473) 2024-04-04 [email protected] Give `generate_gradle_lockfiles.dart` functionality to exclude certain subdirectories (flutter/flutter#146228) 2024-04-04 [email protected] Update documentation to discourage using the TextEditingController.text setter (flutter/flutter#146151) 2024-04-04 [email protected] Roll Flutter Engine from b2ceabf7acce to 03cd54d4285a (1 revision) (flutter/flutter#146292) 2024-04-04 [email protected] Roll Flutter Engine from b435a8a87df0 to b2ceabf7acce (1 revision) (flutter/flutter#146283) 2024-04-04 [email protected] Roll Flutter Engine from bd51ee80d74b to b435a8a87df0 (1 revision) (flutter/flutter#146279) 2024-04-04 [email protected] Roll Packages from 0e848fa to dce6f0c (4 revisions) (flutter/flutter#146276) 2024-04-04 [email protected] Flutter templates example app Gradle memory settings (flutter/flutter#146275) 2024-04-04 [email protected] Roll Flutter Engine from 4303dc0d7a73 to bd51ee80d74b (2 revisions) (flutter/flutter#146273) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md ...
…xt setter (flutter#146151) Fixes flutter#129272 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes
Roll Flutter from ac2ca93 to 477ebd8 (32 revisions) flutter/flutter@ac2ca93...477ebd8 2024-04-05 [email protected] Roll Flutter Engine from 95ffe73ac2a8 to 6974dbac35a1 (2 revisions) (flutter/flutter#146350) 2024-04-05 [email protected] Roll pub packages (flutter/flutter#146348) 2024-04-05 [email protected] Roll Packages from dce6f0c to 764d997 (4 revisions) (flutter/flutter#146344) 2024-04-05 [email protected] Roll Flutter Engine from 292c48b9af5e to 95ffe73ac2a8 (1 revision) (flutter/flutter#146343) 2024-04-05 [email protected] Roll pub packages (flutter/flutter#146331) 2024-04-05 [email protected] Roll Flutter Engine from 23a1d0d2fce6 to 292c48b9af5e (1 revision) (flutter/flutter#146330) 2024-04-05 [email protected] Roll Flutter Engine from 597d33f57183 to 23a1d0d2fce6 (1 revision) (flutter/flutter#146327) 2024-04-05 [email protected] Roll Flutter Engine from 1fa0623bb07f to 597d33f57183 (1 revision) (flutter/flutter#146325) 2024-04-05 [email protected] Roll Flutter Engine from f17d586de6f1 to 1fa0623bb07f (1 revision) (flutter/flutter#146324) 2024-04-05 [email protected] Roll Flutter Engine from d44462a42d73 to f17d586de6f1 (4 revisions) (flutter/flutter#146322) 2024-04-05 [email protected] Fix cursor is not centered when cursorHeight is set (non-Apple platforms). (flutter/flutter#145829) 2024-04-05 [email protected] refactor: Perform plugin resolution per platform (flutter/flutter#144506) 2024-04-04 [email protected] `ExpansionTile` Unable to remove right padding from title (flutter/flutter#145271) 2024-04-04 [email protected] Roll Flutter Engine from dcc99d652154 to d44462a42d73 (1 revision) (flutter/flutter#146311) 2024-04-04 49699333+dependabot[bot]@users.noreply.github.com Bump codecov/codecov-action from 4.1.1 to 4.2.0 (flutter/flutter#146310) 2024-04-04 [email protected] Roll Flutter Engine from e3104af94328 to dcc99d652154 (4 revisions) (flutter/flutter#146308) 2024-04-04 [email protected] Roll Flutter Engine from fa4d97e363ff to e3104af94328 (2 revisions) (flutter/flutter#146300) 2024-04-04 [email protected] Remove dead `compareIosVersions` function (flutter/flutter#146298) 2024-04-04 [email protected] Adds semanticsLabel to MenuItemButton (flutter/flutter#145846) 2024-04-04 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Bump to AGP 8.1/Gradle 8.3 (almost) everywhere (#146181)" (flutter/flutter#146305) 2024-04-04 [email protected] Roll Flutter Engine from 918c72b803cc to fa4d97e363ff (2 revisions) (flutter/flutter#146299) 2024-04-04 [email protected] Bump to AGP 8.1/Gradle 8.3 (almost) everywhere (flutter/flutter#146181) 2024-04-04 [email protected] Roll Flutter Engine from 03cd54d4285a to 918c72b803cc (2 revisions) (flutter/flutter#146296) 2024-04-04 [email protected] Fix InputDecorator suffix and prefix IconButtons ignore `IconButtonTheme` (flutter/flutter#145473) 2024-04-04 [email protected] Give `generate_gradle_lockfiles.dart` functionality to exclude certain subdirectories (flutter/flutter#146228) 2024-04-04 [email protected] Update documentation to discourage using the TextEditingController.text setter (flutter/flutter#146151) 2024-04-04 [email protected] Roll Flutter Engine from b2ceabf7acce to 03cd54d4285a (1 revision) (flutter/flutter#146292) 2024-04-04 [email protected] Roll Flutter Engine from b435a8a87df0 to b2ceabf7acce (1 revision) (flutter/flutter#146283) 2024-04-04 [email protected] Roll Flutter Engine from bd51ee80d74b to b435a8a87df0 (1 revision) (flutter/flutter#146279) 2024-04-04 [email protected] Roll Packages from 0e848fa to dce6f0c (4 revisions) (flutter/flutter#146276) 2024-04-04 [email protected] Flutter templates example app Gradle memory settings (flutter/flutter#146275) 2024-04-04 [email protected] Roll Flutter Engine from 4303dc0d7a73 to bd51ee80d74b (2 revisions) (flutter/flutter#146273) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md ...
Fixes #129272
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.