Skip to content

Remove deprecated RenderEditable.onSelectionChanged#98582

Merged
fluttergithubbot merged 8 commits intoflutter:masterfrom
Piinks:renderEditable
Mar 9, 2022
Merged

Remove deprecated RenderEditable.onSelectionChanged#98582
fluttergithubbot merged 8 commits intoflutter:masterfrom
Piinks:renderEditable

Conversation

@Piinks
Copy link
Contributor

@Piinks Piinks commented Feb 16, 2022

This removes onSelectionChanged from RenderEditable

This deprecated property has reached end of life after the release of Flutter 2.10

Part of #98537
For the full list of deprecations being removed in this batch, see flutter.dev/go/deprecations-removed-after-2-10

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.

@Piinks Piinks added c: contributor-productivity Team-specific productivity, code health, technical debt. framework flutter/packages/flutter repository. See also f: labels. c: API break Backwards-incompatible API changes a: quality A truly polished experience c: tech-debt Technical debt, code quality, testing, etc. labels Feb 16, 2022
@Piinks
Copy link
Contributor Author

Piinks commented Feb 16, 2022

There are some framework tests here that need to be updated

@Piinks
Copy link
Contributor Author

Piinks commented Feb 16, 2022

Also remove the deprecated TextSelectionDelegate setter textEditingValue in this PR, they are related.

@flutter-dashboard

This comment was marked as outdated.

@Piinks Piinks changed the title [WIP] Remove deprecated RenderEditable.onSelectionChanged Remove deprecated RenderEditable.onSelectionChanged Mar 9, 2022
@flutter-dashboard flutter-dashboard bot added the a: text input Entering text in a text field or keyboard related problems label Mar 9, 2022
@Piinks Piinks requested a review from chunhtai March 9, 2022 00:21
affinity: fromPosition.affinity,
);
final bool focusingEmpty = newSelection.baseOffset == 0 && newSelection.extentOffset == 0 && !hasFocus;
if (newSelection == selection && cause != SelectionChangedCause.keyboard && !focusingEmpty) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why does it need to check for other condition if the selection is the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure, I found this change that introduced this: #29563
cc @mdebbar
It was only calling onSelectionChanged under those circumstances.

Without this change, this test from that change fails:

test('selection does not flicker as user is dragging', () {

However, I notice it now causes another failure, so there may be a bug here. One test was expecting one thing from the old API, and the other test is expecting something else from the new API.

Copy link
Contributor

Choose a reason for hiding this comment

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

The old pr only introduce the equal check
if (newSelection != _selection) which makes sense to me, but what about the cause != SelectionChangedCause.keyboard && !focusingEmpty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assumed the logic in _handleSelectionChange was necessary, so I carried it over to the new API. It probably was modified by other changes after #29563. Let me see if removing the keyboard and focus part still passes the existing test.

Copy link
Contributor

Choose a reason for hiding this comment

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

The !focusingEmpty was added in #49000.

The cause != SelectionChangedCause.keyboard was added in #42879.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🙏 Thanks for tracing those back @mdebbar! So I think this is indeed intentional behavior, I am looking at the other test now that is broken here by carrying the logic over.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/flutter/flutter/pull/29809/files is where the test came from, the cupertino one is broken, while the same material test passes, so we may be missing something in cupertino text field.

@Piinks
Copy link
Contributor Author

Piinks commented Mar 9, 2022

Touched base with @justinmc, it looks like the flickering bug #29563 fixed does not exist with the new API. As I understand it, the repeated calls to onSelectionChanged caused the flickering, and so removing onSelectionChanged makes sense to no longer reproduce the bug. I have tested this on Android and iOS and do not see any flickering, so I am going to remove the test.
Thanks all for taking a look. Let me know if there are additional repros or any concerns about a regression here.

Copy link
Contributor

@mdebbar mdebbar left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: quality A truly polished experience a: text input Entering text in a text field or keyboard related problems c: API break Backwards-incompatible API changes c: contributor-productivity Team-specific productivity, code health, technical debt. c: tech-debt Technical debt, code quality, testing, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants