Skip to content

Conversation

@yiiim
Copy link
Member

@yiiim yiiim commented Jan 11, 2024

Fixed the issue of cursor blinking during selection as shown below.

Screen.Recording.2024-01-11.at.23.32.07.mov

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 Jan 11, 2024
Comment on lines 3218 to 3220
// Stop cursor blinking and making it visible.
_stopCursorBlink(resetCharTicks: false);
_cursorBlinkOpacityController.value = 1.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we already call this on FloatingCursorDragState.Start, is something else resetting the cursor blink?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the cursor blinking is reset here when the selection changes. I should note this in the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation. I think given these details, we should probably try prevent the blinking cursor from turning itself back on while the selection is changing due to floating cursor. Maybe by updating the logic in _startOrStopCursorTimerIfNeeded.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have made changes to the implementation, could you please take another look?

@yiiim yiiim requested a review from Renzo-Olivares January 16, 2024 10:28

void _stopCursorBlink({ bool resetCharTicks = true }) {
_cursorBlinkOpacityController.value = 0.0;
_cursorBlinkOpacityController.value = renderEditable.floatingCursorOn ? 1.0 : 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed? Shouldn't _stopCursorBlink stop the cursor blink as expected without changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Even when the floating cursor is displayed, we cannot ignore the call to _stopCursorBlink in _didChangeTextEditingValue, which leads to some test failures. I haven't investigated the specific reasons yet, but I think it's feasible to always keep the cursor visible in _stopCursorBlink when the floating cursor appears. Should I investigate the reasons for the test failures or maintain the status quo?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I've found some clues. We need to set the value of _cursorBlinkOpacityController to stop the animation. This is to avoid re-executing _onCursorTick when the animation ends at this location:

_cursorTimer = Timer(Duration.zero, () => _cursorBlinkOpacityController.animateWith(_iosBlinkCursorSimulation).whenComplete(_onCursorTick));
.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the delay on the review, just ran this locally and I understand what you mean. I'm okay with the code as-is then, but could you add a comment explaining why we take the floating cursor into account.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

void _stopCursorBlink({ bool resetCharTicks = true }) {
_cursorBlinkOpacityController.value = 0.0;
// If the cursor is animating, stop the animation, and we always
// want the cursor to be visible when the floating cursor is enabled
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add period at the end of this comment.

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.

LGTM with small nit. Thank you for the contribution!

@justinmc justinmc self-requested a review February 1, 2024 23:12
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 👍

Good catch, thanks for fixing this! Is there an issue anywhere about this that you're aware of?

@justinmc justinmc merged commit 16e7218 into flutter:master Feb 7, 2024
@yiiim
Copy link
Member Author

yiiim commented Feb 8, 2024

LGTM 👍

Good catch, thanks for fixing this! Is there an issue anywhere about this that you're aware of?

There is no related issue, this is a problem found after my other PR#138479.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 8, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 8, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Feb 8, 2024
Roll Flutter from 8431cae to eb5d0a4 (33 revisions)

flutter/flutter@8431cae...eb5d0a4

2024-02-08 [email protected] Roll Packages from e4ea6bf to 29d8cc0 (5 revisions) (flutter/flutter#143161)
2024-02-08 [email protected] Roll Flutter Engine from 6d524588c0f9 to f53fbd8393ce (1 revision) (flutter/flutter#143160)
2024-02-08 [email protected] Roll Flutter Engine from 22e1241e9823 to 6d524588c0f9 (3 revisions) (flutter/flutter#143147)
2024-02-08 [email protected] Roll Flutter Engine from 084bd0b8f5ac to 22e1241e9823 (1 revision) (flutter/flutter#143140)
2024-02-08 [email protected] Roll Flutter Engine from 104804aa374e to 084bd0b8f5ac (1 revision) (flutter/flutter#143139)
2024-02-08 [email protected] Roll Flutter Engine from 45137ea6ba29 to 104804aa374e (1 revision) (flutter/flutter#143138)
2024-02-08 [email protected] Pass along web renderer into debugging options in the test command. (flutter/flutter#143128)
2024-02-08 [email protected] Roll Flutter Engine from 4ea7bd07328b to 45137ea6ba29 (2 revisions) (flutter/flutter#143135)
2024-02-08 [email protected] Roll Flutter Engine from 322a461dc74f to 4ea7bd07328b (2 revisions) (flutter/flutter#143131)
2024-02-07 [email protected] Add a unit test for `NavigationRail` (flutter/flutter#143108)
2024-02-07 [email protected] Roll Flutter Engine from b1ba9f329f76 to 322a461dc74f (2 revisions) (flutter/flutter#143123)
2024-02-07 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Improve build output for all platforms" (flutter/flutter#143125)
2024-02-07 [email protected] Roll Flutter Engine from e4a5acc14b44 to b1ba9f329f76 (2 revisions) (flutter/flutter#143120)
2024-02-07 [email protected] Improve build output for all platforms (flutter/flutter#128236)
2024-02-07 [email protected] Roll Flutter Engine from 19ae46afed69 to e4a5acc14b44 (7 revisions) (flutter/flutter#143112)
2024-02-07 [email protected] Fixed cursor blinking during selection. (flutter/flutter#141380)
2024-02-07 [email protected] Remove Cirrus check for web test concurrency (flutter/flutter#143046)
2024-02-07 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Enforce a policy on supported Gradle, Java, AGP, and KGP versions" (flutter/flutter#143114)
2024-02-07 [email protected] Enforce a policy on supported Gradle, Java, AGP, and KGP versions (flutter/flutter#142000)
2024-02-07 [email protected] Fix inputs and outputs for `WebReleaseBundle` (flutter/flutter#143023)
2024-02-07 [email protected] Various improvements to text-editing-related documentation. (flutter/flutter#142561)
2024-02-07 [email protected] Revert "Add `SingleChildScrollView` for `NavigationRail`" (flutter/flutter#143097)
2024-02-07 [email protected] Restore log dumps for gradle OOM crashes, and set a value for `MaxMetaspaceSize` (flutter/flutter#143085)
2024-02-07 [email protected] Move Mac_build_test flutter_gallery__transition_perf_e2e_ios out of staging (flutter/flutter#142987)
2024-02-07 [email protected] Roll Flutter Engine from fafd8e55eb4b to 19ae46afed69 (1 revision) (flutter/flutter#143094)
2024-02-07 [email protected] Add a test for the isAvailableForEnvironment logic (flutter/flutter#142251)
2024-02-07 [email protected] Add the number of mismatched pixels to golden tests output (flutter/flutter#142975)
2024-02-07 [email protected] Add indexInParent to SemanticsNode debug information (flutter/flutter#142826)
2024-02-07 [email protected] Remove unused devicelab task gradle_non_android_plugin_test (flutter/flutter#142742)
2024-02-07 [email protected] Make generate_gradle_lockfiles also write the gradle wrapper file (flutter/flutter#142329)
2024-02-07 [email protected] Roll Flutter Engine from 6807342305e4 to fafd8e55eb4b (1 revision) (flutter/flutter#143086)
2024-02-07 [email protected] Remove redundant `rootDirectoryPath` parameter in `DevFS::update` (flutter/flutter#143034)
2024-02-07 [email protected] Handle transitions to AppLifecycleState.detached in lifecycle state generation (flutter/flutter#142523)

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:
...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 14, 2024
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 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.

3 participants