Skip to content
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

TextSelectionHandleControls deprecation deletion timeframe #124262

Conversation

justinmc
Copy link
Contributor

@justinmc justinmc commented Apr 5, 2023

This came out of this discussion on another PR. This PR executes "Option 2" in my list of options.

Currently, TextSelectionControls.buildToolbar and TextSelectionHandleControls have the same deprecation version, which implies that they will both be deleted at the same time. This creates a problematic migration for users:

  1. Receive a deprecation warning. Migrate from TextSelectionControls.buildToolbar to EditableText.buildContextMenuand fromTextSelectionControls.buildHandletoTextSelectionHandleControls.buildHandle`.
  2. Receive a sudden breakage when TextSelectionHandleControls is deleted, and have to migrate immediately back to TextSelectionControls.buildHandle.

Instead, I've bumped the deprecation version so that the deletion happens in two stages. This results in a two-stage migration process and avoids the sudden breaking change:

  1. (Same as before) Receive a deprecation warning. Migrate from TextSelectionControls.buildToolbar to EditableText.buildContextMenu and from TextSelectionControls.buildHandle to TextSelectionHandleControls.buildHandle.
  2. Receive another deprecation warning when TextSelectionControls.buildToolbar is removed. Migrate from TextSelectionHandleControls.buildToolbar back to TextSelectionControls.buildToolbar.
  3. TextSelectionHandleControls is removed safely.

…ionControls.buildToolbar, to avoid a sudden breaking change when both are removed
@justinmc justinmc self-assigned this Apr 5, 2023
@flutter-dashboard flutter-dashboard bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. labels Apr 5, 2023
@flutter-dashboard
Copy link

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 Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on 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.

@Piinks Piinks added the c: tech-debt Technical debt, code quality, testing, etc. label Apr 5, 2023
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

I think this SGTM. If we need to extend the other deprecations further, we can always do that too. Later even if we decide it is needed.

Are there any dart fixes for these? I don't think dart fix can help with replacing mixins, but there could be some assistance from dart fix for the other related APIs that are deprecated for this.

We learned when the typography changes from 2014 (A) were replaced by the 2018 (B) and then the current (C), dart fix will actually migrate A directly to C, skipping B. :)

@gnprice
Copy link
Member

gnprice commented Apr 6, 2023

Instead, I've bumped the deprecation version so that the deletion happens in two stages. This results in a two-stage migration process and avoids the sudden breaking change

This sounds great.

I wonder if it'd be helpful to go a step farther and delete the @Deprecated annotation on this class entirely. If I'm understanding correctly, any deprecation warning that it causes is not going to be actionable right now — this is version B of the API, and C isn't yet available. Then when adding C, we can add back this @Deprecated annotation.

There could still be text in the class's doc explaining that the plan is this will be removed in the future after C is available. But by removing the formal annotation, any developers who see the strikethrough on this class's name in their IDE when they use it won't be frustrated wondering what it is they're supposed to do instead. Nor have to keep looking at the strikethrough if they're trying to keep their project all clean and up to date 🙂

@justinmc
Copy link
Contributor Author

justinmc commented Apr 6, 2023

Good point! I agree, I'll remove the deprecation altogether and replace it with a TODO for myself to deprecate it later.

@justinmc
Copy link
Contributor Author

justinmc commented Apr 6, 2023

@Piinks There are no dart fixes. The simplest thing would be helping to migrate from TextSelectionControls.buildToolbar to TextField.contextMenuBuilder (or CupertinoTextField or TextFormField). But this deprecation has already been released on stable, so I'm guessing most users have already migrated (A to B).

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

LGTM!

@Hixie
Copy link
Contributor

Hixie commented Apr 6, 2023

test-exempt: annotation change

...but I have to say, this doesn't seem like the most fun for developers. I don't really understand the situation in detail but it seems like we should find some way to automigrate people to the final API in one go, and not have them worry about any of this at all.

@justinmc
Copy link
Contributor Author

justinmc commented Apr 6, 2023

I agree, this one is my bad. I should have just deprecated all of TextSelectionControls and permanently moved everyone to TextSelectionHandleControls in one step. I thought I could be clever with this 2 step approach since it only should affect a small number of users, but it's too complicated.

Anyway, this PR will make it a little better by at least having two clear, separate migration steps.

@justinmc justinmc merged commit e4f2d61 into flutter:master Apr 6, 2023
@justinmc justinmc deleted the text-selection-handle-controls-staged-deprecation branch April 6, 2023 21:00
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 7, 2023
exaby73 pushed a commit to NevercodeHQ/flutter that referenced this pull request Apr 17, 2023
…24262)

Make sure the removal of deprecated APIs TextSelectionControls.buildToolbar and TextSelectionHandleControls happen in two separate steps.  Will make a tricky migration situation a little easier for affected users.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
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 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