Keep last character obscured when toggling obscureText#183488
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. 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. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
|
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. |
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where the last character of an obscured text field could be briefly revealed when the obscureText property is toggled. The change resets a timer responsible for showing the last character whenever obscureText changes. My feedback includes a suggestion to improve a code comment for clarity.
Note: Security Review is unavailable for this PR.
| //reset to prevent the last character in obscure text | ||
| _obscureShowCharTicksPending = 0; |
There was a problem hiding this comment.
This comment could be more descriptive and adhere to the Dart style guide by starting with a capital letter. A clearer comment would explain why _obscureShowCharTicksPending is reset when obscureText changes.
// When `obscureText` is toggled, we should not be in the middle of revealing a character.
_obscureShowCharTicksPending = 0;References
- The repository style guide defers to 'Effective Dart: Style' (line 20), which recommends capitalizing comments like sentences. (link)
- The repository style guide states that documentation should be useful and explain the 'why' and the 'how' (line 55). A more descriptive comment would improve readability. (link)
|
@TrangLeQuynh thank you for the contribution! Before moving forward with this PR you will need to sign the CLA and write a test to verify that the expected behavior works after the change. |
cceccf4 to
e23fac8
Compare
|
@Renzo-Olivares Thanks for the feedback. I have now signed the CLA and added the test to verify the expected behavior. Please take another look when you have a moment. |
Renzo-Olivares
left a comment
There was a problem hiding this comment.
Hi @TrangLeQuynh, thank you for the contribution! Left a few comments.
| @@ -3406,6 +3406,8 @@ class EditableTextState extends State<EditableText> | |||
| if (_hasInputConnection) { | |||
| if (oldWidget.obscureText != widget.obscureText || | |||
| oldWidget.keyboardType != widget.keyboardType) { | |||
There was a problem hiding this comment.
I think it sounds reasonable to reset this last obscure character when the keyboard type changes but curious to hear others thoughts. In triage we discussed only resetting when obscureText changes.
1a8b16d to
a1b6f75
Compare
|
@Renzo-Olivares I have updated according to your comment. On non-mobile platforms, the last character of the obscure text is not briefly revealed. Therefore, this bug only occurs on mobile, and tests need to explicitly cover mobile platforms(iOS, Android, Fuchsia) instead of relying on the default. |
a1b6f75 to
cf51291
Compare
Renzo-Olivares
left a comment
There was a problem hiding this comment.
LGTM pending my last nit
cf51291 to
685af95
Compare
Renzo-Olivares
left a comment
There was a problem hiding this comment.
LGTM, thank you for the contribution @TrangLeQuynh!
|
@TrangLeQuynh it looks like this comment hasn't been addressed yet: #183488 (comment) Also it looks like there's some analysis errors: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8685868144703014273/+/u/run_analyzer_benchmark/stdout |
685af95 to
d3270da
Compare
5cee2d8 to
449d9e7
Compare
flutter/flutter@9cd60b5...a0924c7 2026-04-07 dacoharkes@google.com Reland "[data_assets] Cleanup tests" (flutter/flutter#184714) 2026-04-07 matt.kosarek@canonical.com Use the WindowRegistry in the multiple_windows example app (flutter/flutter#184579) 2026-04-07 15619084+vashworth@users.noreply.github.com Introduce command to build a swift package for SwiftPM add to app integration (flutter/flutter#184660) 2026-04-07 sigurdm@google.com Have `flutter create` create a pubspec.lock to ensure pinned versions are being used. (flutter/flutter#175352) 2026-04-07 59215665+davidhicks980@users.noreply.github.com [widgets/raw_menu_anchor.dart] Always call onClose and onCloseRequested on descendants before parent. (flutter/flutter#182357) 2026-04-07 rmolivares@renzo-olivares.dev `WindowsPlugin` should not crash when ffiPlugin enabled (flutter/flutter#184695) 2026-04-06 97480502+b-luk@users.noreply.github.com Use full goto.google.com hostname for go/ links (flutter/flutter#184679) 2026-04-06 34871572+gmackall@users.noreply.github.com Apply rect clipping to surface views (flutter/flutter#184471) 2026-04-06 jhy03261997@gmail.com [A11y] Allow percentage strings like "50%" as `SemanticsValue` for `ProgressIndicator` (flutter/flutter#183670) 2026-04-06 louisehsu@google.com Fix invisible accessibility element before scroll view (flutter/flutter#184155) 2026-04-06 engine-flutter-autoroll@skia.org Roll Skia from 163dfdf500c7 to e264d870a380 (2 revisions) (flutter/flutter#184674) 2026-04-06 54688429+TrangLeQuynh@users.noreply.github.com Keep last character obscured when toggling obscureText (flutter/flutter#183488) 2026-04-06 15619084+vashworth@users.noreply.github.com Parse scheme file with XML parser for SwiftPM migrator (flutter/flutter#184525) 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 bmparr@google.com,stuartmorgan@google.com 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
…perty toggle on or off ### Summary When `obscureText` is toggled quickly from true → false → true, the most recently entered character is shown in an obscured text field. Fixes flutter#184483 ### Steps to restore 1. Create a TextField with `obscureText = true`. 2. Quickly type some text. 3. Toggle `obscureText` to **false**. 4. Immediately toggle it back to **true**. 5. Observe the displayed text. > Note: This behavior occurs when the operations are performed quickly (≤ ~1500 ms), due to defaults: > > ```dart > // The time it takes for the cursor to fade from fully opaque to fully >// transparent and vice versa. A full cursor blink, from transparent to opaque >// to transparent, is twice this duration. >const Duration _kCursorBlinkHalfPeriod = Duration(milliseconds: 500); > >// Number of cursor ticks during which the most recently entered character >// is shown in an obscured text field. >const int _kObscureShowLatestCharCursorTicks = 3; > ``` ### Actual Result The most recently entered character may still be visible briefly after `obscureText` is set back to true https://github.com/user-attachments/assets/94d2ba56-c551-4385-8f88-3dd746c8dc09 ### Expect result When `obscureText` is updated to true, all characters should be immediately obscured, regardless of previously revealed characters. https://github.com/user-attachments/assets/992e0473-059c-4c7a-a1b1-8ca6bf222538
…r#11463) flutter/flutter@9cd60b5...a0924c7 2026-04-07 dacoharkes@google.com Reland "[data_assets] Cleanup tests" (flutter/flutter#184714) 2026-04-07 matt.kosarek@canonical.com Use the WindowRegistry in the multiple_windows example app (flutter/flutter#184579) 2026-04-07 15619084+vashworth@users.noreply.github.com Introduce command to build a swift package for SwiftPM add to app integration (flutter/flutter#184660) 2026-04-07 sigurdm@google.com Have `flutter create` create a pubspec.lock to ensure pinned versions are being used. (flutter/flutter#175352) 2026-04-07 59215665+davidhicks980@users.noreply.github.com [widgets/raw_menu_anchor.dart] Always call onClose and onCloseRequested on descendants before parent. (flutter/flutter#182357) 2026-04-07 rmolivares@renzo-olivares.dev `WindowsPlugin` should not crash when ffiPlugin enabled (flutter/flutter#184695) 2026-04-06 97480502+b-luk@users.noreply.github.com Use full goto.google.com hostname for go/ links (flutter/flutter#184679) 2026-04-06 34871572+gmackall@users.noreply.github.com Apply rect clipping to surface views (flutter/flutter#184471) 2026-04-06 jhy03261997@gmail.com [A11y] Allow percentage strings like "50%" as `SemanticsValue` for `ProgressIndicator` (flutter/flutter#183670) 2026-04-06 louisehsu@google.com Fix invisible accessibility element before scroll view (flutter/flutter#184155) 2026-04-06 engine-flutter-autoroll@skia.org Roll Skia from 163dfdf500c7 to e264d870a380 (2 revisions) (flutter/flutter#184674) 2026-04-06 54688429+TrangLeQuynh@users.noreply.github.com Keep last character obscured when toggling obscureText (flutter/flutter#183488) 2026-04-06 15619084+vashworth@users.noreply.github.com Parse scheme file with XML parser for SwiftPM migrator (flutter/flutter#184525) 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 bmparr@google.com,stuartmorgan@google.com 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
…perty toggle on or off
Summary
When
obscureTextis toggled quickly from true → false → true, the most recently entered character is shown in an obscured text field.Fixes #184483
Steps to restore
Create a TextField with
obscureText = true.Quickly type some text.
Toggle
obscureTextto false.Immediately toggle it back to true.
Observe the displayed text.
Actual Result
The most recently entered character may still be visible briefly after
obscureTextis set back to trueobscureText_1.mov
Expect result
When
obscureTextis updated to true, all characters should be immediately obscured, regardless of previously revealed characters.obscureText_2.mov