Skip to content

Conversation

@justinmc
Copy link
Contributor

Fixes #122421

In that issue, someone was confused that using both contextMenuBuilder and TextSelectionControls.buildHandle ignored contextMenuBuilder. This is intentional due to deprecations. The correct way is to use TextSelectionHandleControls.buildHandle.

This PR clarifies this in the docs.

CC @cottonman132

@justinmc justinmc requested a review from Renzo-Olivares March 30, 2023 23:29
@justinmc justinmc self-assigned this Mar 30, 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 Mar 30, 2023
Comment on lines 77 to 81
/// To use both [EditableText.contextMenuBuilder] and [buildHandle] during this
/// deprecation period, use [TextSelectionHandleControls]. This class was
/// created as a stopgap during the deprecation period. After the deprecations
/// are removed, [TextSelectionControls.buildToolbar] and
/// [TextSelectionHandleControls] will be gone. The only way to customize
Copy link
Member

Choose a reason for hiding this comment

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

It sounds like this is saying that the thing you should do now is something that will stop working in the future. Am I understanding it correctly?

Is there planned to be a point in the future where the new way has started working, but this interim way is still working and hasn't yet been removed? I think it would be quite helpful to make that be the case, so that people can go step by step through

  1. upgrade Flutter to version N;
  2. update their code to the new way;
  3. upgrade Flutter to version M > N;

and have a working app at each step.

As is, it sounds like perhaps the new way to handle this use case will only begin to work correctly at the same time as the interim way gets removed, which will make upgrades more challenging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good point, I didn't fully think this through when I planned this deprecation. I probably should have fully deprecated TextSelectionControls and replaced it with TextSelectionHandleControls. But given that I didn't...

Option 1: Immediate breaking change (current)

Remove the methods from TextSelectionControls and remove TextSelectionHandleControls at the same time.

Affected people (those using both contextMenuBuilder and TextSelectionControls) will have to migrate to TextSelectionHandleControls, then face an immediate breaking change when it is removed and have to migrate back to TextSelectionControls.

Option 2: Two stage deprecation

Remove the methods from TextSelectionControls first. At this point, TextSelectionControls and TextSelectionHandleControls are identical but TextSelectionHandleControls is deprecated. In the second stage, remove TextSelectionHandleControls.

Affected people will migrate to TextSelectionHandleControls, then get a warning that it is deprecated and migrate back to TextSelectionControls.

Option 3: More breaking changes

I could potentially try to jump back on the path I should have taken from the start, by un-deprecating TextSelectionHandleControls and deprecating TextSelectionControls.

A slight negative of this plan is for people who were only using TextSelectionControls for building handles and didn't care about toolbars. They would never be affected by the previous two options, but they would have to migrate to TextSelectionHandleControls under this third option.

For the record, why did I do this in the first place?

I needed a way to distinguish between the old path (TextSelectionControls.buildToolbar) and new path (contextMenuBuilder) because during the deprecation period, both need to work simultaneously. The way I could determine which to use is if selectionControls is TextSelectionHandleControls, then they definitely want to use the new post-deprecation path. Otherwise I would continue to use buildToolbar during the deprecation period.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Piinks Do you have any thoughts on this deprecation conundrum? 🌪️

Copy link
Contributor

Choose a reason for hiding this comment

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

Happy to help! In general, if we want folks to ultimately migrate from API A to C, we should make that path available to them in as easy a transition as possible. If there is a migration from A to B to C, this is a lot of churn on developers.

This class was created as a stopgap during the deprecation period.

Usually we try to avoid this, will this work after the deprecation period and also be deprecated for a while, maintaining backwards compatibility? Otherwise, it looks like it may just be a hard break that has been kicked down the road for the future.

Is there currently a migration path that exists as a final destination for developers? As in, can a developer migrate from the currently deprecated API A to the final API C that they should be using going forward? If so, we should deprecate this temp class now so folks can move gracefully. Any other associated deprecations can be updated to extend the deprecation period.

If the final destination path to C is not available yet, here is an option we could take.. when the final destination C is available, deprecate this temp class and update the current deprecations to extend the period. That way folks can easily transition to the end goal API C when it is ready. It seems pretty easy all around for everyone since it won't require rolling anything back or making a hard break, just a little more time to allow folks to migrate.

However, I don't have 100% context here. Should EditableText.contextMenuBuilder be deprecated? Is that the API that folks should not be using? What is the A B C of this equation? :)

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 your thoughts! For the purpose of ultimately migrating from TextSelectionControls.buildToolbar to EditableText.contextMenuBuilder, your equation would be:

  • A: TextSelectionControls.buildToolbar and TextSelectionControls.buildHandle
  • B: EditableText.contextMenuBuilder and TextSelectionHandleControls.buildHandle
  • C: EditableText.contextMenuBuilder and TextSelectionControls.buildHandle

There is no final destination path from A to C right now. It's not possible for developers to migrate to C until TextSelectionHandleControls has been deleted.

If I don't want all of the deprecations to be removed at the same time, then can I just update the "This feature was deprecated after vx.x.x" string? Looks like it currently says v3.3.0-0.5.pre, but the latest is 3.9.0-21.0.pre. If so I should probably do that immediately, before the release.

I would consider option 3, which would make this just an A=>B kind of migration, but it would require nontrivial changes that I don't want to try to get into the release right now.

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've opened a PR to do this if I understand correctly (Option 2). #124262

Comment on lines 77 to 78
/// To use both [EditableText.contextMenuBuilder] and [buildHandle] during this
/// deprecation period, use [TextSelectionHandleControls]. This class was
Copy link
Member

Choose a reason for hiding this comment

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

Should this perhaps be mentioned on [EditableText.contextMenuBuilder] and/or on [buildHandle]?

@justinmc
Copy link
Contributor Author

@Piinks @gnprice I have moved to a two-step deprecation process as discussed above, using PRs #124262 and #124611. I've updated the docs in this PR to reflect that.

@justinmc justinmc requested review from Piinks and gnprice April 12, 2023 18:49
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

@justinmc justinmc merged commit 62cb61d into flutter:master Apr 13, 2023
@justinmc justinmc deleted the context-menu-deprecation-docs branch April 13, 2023 17:13
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 14, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Apr 14, 2023
flutter/flutter@be45eb2...f740544

2023-04-14 [email protected] Roll Flutter Engine from b7b2e7b742aa to 4b96e38c9275 (1 revision) (flutter/flutter#124856)
2023-04-14 [email protected] Adjust repo config for VS Code formatting (flutter/flutter#122758)
2023-04-14 [email protected] Roll Flutter Engine from 4f86a05ac932 to b7b2e7b742aa (4 revisions) (flutter/flutter#124845)
2023-04-14 [email protected] Roll Flutter Engine from 00bef00f64a7 to 4f86a05ac932 (5 revisions) (flutter/flutter#124841)
2023-04-14 [email protected] Roll Flutter Engine from ad222b0c93b9 to 00bef00f64a7 (1 revision) (flutter/flutter#124837)
2023-04-14 [email protected] [flutter_tools] Reorganize android_studio_test.dart (flutter/flutter#124834)
2023-04-14 [email protected] Roll Flutter Engine from ce7be0093399 to ad222b0c93b9 (1 revision) (flutter/flutter#124832)
2023-04-14 [email protected] Remove Finder extended attributes in build target before code signing iOS frameworks (flutter/flutter#123896)
2023-04-14 [email protected] flutter-tool, web: update HTML template serviceWorkerVersion to be const (flutter/flutter#124826)
2023-04-14 [email protected] Fix `CupertinoContextMenu` throws exception on route animation (flutter/flutter#124785)
2023-04-14 [email protected] flutter-tool: enum cleanup (flutter/flutter#124760)
2023-04-14 [email protected] Roll Flutter Engine from 1289f4b513ef to ce7be0093399 (1 revision) (flutter/flutter#124825)
2023-04-13 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 3.5.1 to 3.5.2 (flutter/flutter#124822)
2023-04-13 [email protected] Roll Flutter Engine from 2ff14d733daa to 1289f4b513ef (2 revisions) (flutter/flutter#124824)
2023-04-13 [email protected] Roll Flutter Engine from eb3e7d52ebbc to 2ff14d733daa (1 revision) (flutter/flutter#124820)
2023-04-13 [email protected] i123643 print java version gradle (flutter/flutter#123644)
2023-04-13 [email protected] Roll Flutter Engine from 496543715bdb to eb3e7d52ebbc (3 revisions) (flutter/flutter#124816)
2023-04-13 [email protected] Roll pub packages (flutter/flutter#124709)
2023-04-13 [email protected] [flutter_tools] Disable flaky `output_web_test` test case (flutter/flutter#124257)
2023-04-13 [email protected] Roll Flutter Engine from 26eddb64e8ea to 496543715bdb (1 revision) (flutter/flutter#124812)
2023-04-13 [email protected] Refactor `SliverAppBar.medium` & `SliverAppBar.large` to fix several issues (flutter/flutter#122542)
2023-04-13 [email protected] Improve the docs around the TextSelectionHandleControls deprecations (flutter/flutter#123827)
2023-04-13 [email protected] Roll Packages from fe5615f to d01f4ea (5 revisions) (flutter/flutter#124795)
2023-04-13 [email protected] Roll Flutter Engine from 81a57d24e62a to 26eddb64e8ea (1 revision) (flutter/flutter#124794)

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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
exaby73 pushed a commit to exaby73/flutter_nevercode that referenced this pull request Apr 17, 2023
…lutter#123827)

Explain how to do the two-step migration to the context menus feature.
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
flutter/flutter@be45eb2...f740544

2023-04-14 [email protected] Roll Flutter Engine from b7b2e7b742aa to 4b96e38c9275 (1 revision) (flutter/flutter#124856)
2023-04-14 [email protected] Adjust repo config for VS Code formatting (flutter/flutter#122758)
2023-04-14 [email protected] Roll Flutter Engine from 4f86a05ac932 to b7b2e7b742aa (4 revisions) (flutter/flutter#124845)
2023-04-14 [email protected] Roll Flutter Engine from 00bef00f64a7 to 4f86a05ac932 (5 revisions) (flutter/flutter#124841)
2023-04-14 [email protected] Roll Flutter Engine from ad222b0c93b9 to 00bef00f64a7 (1 revision) (flutter/flutter#124837)
2023-04-14 [email protected] [flutter_tools] Reorganize android_studio_test.dart (flutter/flutter#124834)
2023-04-14 [email protected] Roll Flutter Engine from ce7be0093399 to ad222b0c93b9 (1 revision) (flutter/flutter#124832)
2023-04-14 [email protected] Remove Finder extended attributes in build target before code signing iOS frameworks (flutter/flutter#123896)
2023-04-14 [email protected] flutter-tool, web: update HTML template serviceWorkerVersion to be const (flutter/flutter#124826)
2023-04-14 [email protected] Fix `CupertinoContextMenu` throws exception on route animation (flutter/flutter#124785)
2023-04-14 [email protected] flutter-tool: enum cleanup (flutter/flutter#124760)
2023-04-14 [email protected] Roll Flutter Engine from 1289f4b513ef to ce7be0093399 (1 revision) (flutter/flutter#124825)
2023-04-13 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 3.5.1 to 3.5.2 (flutter/flutter#124822)
2023-04-13 [email protected] Roll Flutter Engine from 2ff14d733daa to 1289f4b513ef (2 revisions) (flutter/flutter#124824)
2023-04-13 [email protected] Roll Flutter Engine from eb3e7d52ebbc to 2ff14d733daa (1 revision) (flutter/flutter#124820)
2023-04-13 [email protected] i123643 print java version gradle (flutter/flutter#123644)
2023-04-13 [email protected] Roll Flutter Engine from 496543715bdb to eb3e7d52ebbc (3 revisions) (flutter/flutter#124816)
2023-04-13 [email protected] Roll pub packages (flutter/flutter#124709)
2023-04-13 [email protected] [flutter_tools] Disable flaky `output_web_test` test case (flutter/flutter#124257)
2023-04-13 [email protected] Roll Flutter Engine from 26eddb64e8ea to 496543715bdb (1 revision) (flutter/flutter#124812)
2023-04-13 [email protected] Refactor `SliverAppBar.medium` & `SliverAppBar.large` to fix several issues (flutter/flutter#122542)
2023-04-13 [email protected] Improve the docs around the TextSelectionHandleControls deprecations (flutter/flutter#123827)
2023-04-13 [email protected] Roll Packages from fe5615f to d01f4ea (5 revisions) (flutter/flutter#124795)
2023-04-13 [email protected] Roll Flutter Engine from 81a57d24e62a to 26eddb64e8ea (1 revision) (flutter/flutter#124794)

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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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 framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextField contextMenuBuilder is not used when passing selectionControls on mobile

4 participants