Skip to content

[flutter_markdown] Use Text.rich to replace RichText in Flutter Markdown #6062

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

Merged
merged 15 commits into from
Feb 13, 2024

Conversation

leiatfly
Copy link
Contributor

@leiatfly leiatfly commented Feb 6, 2024

With this PR, a client can use SelectionArea to handle selected text in Markdown.

When setting selectable to false, the Markdown widget renders Text, which can be wrapped in SelectionArea for client-defined behavior (i.e., the Markdown widget no longer consumes the selection event).

When setting selectable to true, the Markdown widget handles the selection behavior, as before this change.

This fixes issue #107073 and is related to issue #113530.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

With this commit, a client can use SelectionArea to handle selected text. 

When setting `selectable` to false, the Markdown widget renders Text, which can be wrapped in SelectionArea for client-defined behavior (i.e., the Markdown widget no longer consumes the selection event). 

When setting `selectable` to true, the Markdown widget handles the selection behavior, as before this change.

This is related to issue #107073 and issue #113530.
@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 "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use 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.

Copy link

google-cla bot commented Feb 6, 2024

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.

@leiatfly leiatfly changed the title Use Text.rich to replace RichText in Flutter Markdown [flutter_markdown] Use Text.rich to replace RichText in Flutter Markdown Feb 6, 2024
leiatfly and others added 6 commits February 6, 2024 12:55
With this commit, a client can use SelectionArea to handle selected text.

When setting `selectable` to false, the Markdown widget renders Text, which can be wrapped in SelectionArea for client-defined behavior (i.e., the Markdown widget no longer consumes the selection event).

When setting `selectable` to true, the Markdown widget handles the selection behavior, as before this change.

This is related to issue #107073 and issue #113530.
@leiatfly
Copy link
Contributor Author

leiatfly commented Feb 7, 2024

Hi, I've now modified all the affected tests and have all checks passed. Could you please merge the PR?

@domesticmouse
Copy link
Contributor

PTAL @stuartmorgan

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

With this PR, a client can use SelectionArea to handle selected text in Markdown.

[...]

This is related to issue #107073 and issue #113530.

Does it fix 107173? If so, please update the description to say so explicitly.

  • I added new tests to check the change I am making, or this PR is test-exempt.

Where is the new test that validates that the change described in the PR is actually working (and does not regress in the future)? I just see boilerplate changes to existing tests.

@leiatfly
Copy link
Contributor Author

leiatfly commented Feb 8, 2024

Thanks for the review, PTAL @stuartmorgan

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Minor changelog nits, but otherwise looks good.

@@ -1,3 +1,7 @@
## 0.6.19

* Uses `Text.rich` to replace `RichText` so the widget can work with `SelectionArea` when `selectable` set to false.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: is set to false

@@ -1,3 +1,7 @@
## 0.6.19

* Uses `Text.rich` to replace `RichText` so the widget can work with `SelectionArea` when `selectable` set to false.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Replaces RichText with Text.rich

@peixinli peixinli merged commit 49e3f1c into flutter:main Feb 13, 2024
@stuartmorgan-g
Copy link
Contributor

@peixinli In the future, please use the autosubmit label; manual merges bypass checks and load balancing, and are strongly discouraged in Flutter.

@peixinli
Copy link
Contributor

@peixinli In the future, please use the autosubmit label; manual merges bypass checks and load balancing, and are strongly discouraged in Flutter.

Sorry about that. Will do next time! Let me know if you think we need to revert.

@stuartmorgan-g
Copy link
Contributor

No need for a revert, just something to minimize in the future.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 14, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Feb 14, 2024
flutter/packages@9385bbb...a864254

2024-02-14 matanlurey@users.noreply.github.com Allow deprecated members from the Dart SDK/Flutter Framework to roll in (flutter/packages#6111)
2024-02-14 43054281+camsim99@users.noreply.github.com [google_maps_flutter][iOS 12] Skip `testTakeSnapshot` (flutter/packages#6120)
2024-02-13 stuartmorgan@google.com [ci] Allow dependencies on local_auth_ios (flutter/packages#6116)
2024-02-13 40719830+Alex-Usmanov@users.noreply.github.com [url_launcher] Add `InAppBrowserConfiguration` parameter in implementations (flutter/packages#5759)
2024-02-13 16229121+leiatfly@users.noreply.github.com [flutter_markdown] Use Text.rich to replace RichText in Flutter Markdown (flutter/packages#6062)
2024-02-13 97943118+GavrielRosendorn74@users.noreply.github.com [google_maps_flutter][iOS 17] takeSnapshot FIX (flutter/packages#5823)

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-flutter-autoroll
Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: 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
auto-submit bot pushed a commit that referenced this pull request Mar 18, 2024
With this PR, a client can use 'onSelectionChanged' to handle selected text in Markdown.

This provides another way to fix issue [#107073](flutter/flutter#107073), along with the prior solution in [PR/6062](#6062)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants