[web] Text Selection does not work Across Multiple Widgets

It is currently impossible to select text across multiple widgets in Flutter, even with SelectableText. This is because you can only select the text inside one SelectableText at a time.

Background

Flutter enables text selection using SelectableText, otherwise text is not selectable on web. Regarding the difference between regular HTML-based web apps and Flutter-based web apps, the narrative is the following:

You can disable text selection on the Web: […]

The difference is that Flutter makes text not selectable by default. For consistency with Flutter on all other platforms we’d like to keep the current default.

(From this comment from @yjbanov)

Comparison

The difference in terms of text selection across multiple “widgets” is that in regular HTML-based apps, you can select text across the whole page. In Flutter, it only works within one SelectableText widget.

Flutter-based web apps


Screen.Recording.2021-04-02.at.09.41.14.mov


HTML-based web apps


Screen.Recording.2021-04-02.at.09.48.44.mov


Feature request

Considering the Background above, it sounds like the current text selection support is considered equivalent to normal web text selection. However, I think this is not currently the case (also considering #63576 for example).

If you think about the feasibility of making text selectable by default in your app, it is very inconvenient because you need to do multiple things:

  1. Replace all Text widgets by SelectableText widgets.
  2. Make sure this is the case only on web, i.e. you want Text widgets on mobile instead.
  3. Live with the fact that text selection across multiple widgets does not work. This is especially cumbersome if you are using many smaller text widgets rather than one big one (which is often the case).

For this feature to be considered supported, solving at least point 3. is necessary. Solving point 1. and 2. also seems like it should be done (although it is technically not necessary) in order to make it less cumbersome to work with.

2 thoughts on “[web] Text Selection does not work Across Multiple Widgets

  1. @creativecreatorormaybenot I think he was actually referring to an open source rich text editor he was working on. So what he implemented for us was simpler compared to the challenges he’s dealing with over there. Let me get back to you next week on the best way forward. We could just throw something rough up on a GitHub repo somewhere to start 🙂

  2. Yes, I’ve been very busy with text selection this year, from an editor, to the Engage video, to Turtle’s use-cases 🙂

    Whenever the editor is ready to ship, I’m sure we’ll have some public announcements.