-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
flutter/engine
#23162Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: typographyText rendering, possibly libtxtText rendering, possibly libtxtcustomer: junecustomer: web10found in release: 1.21Found to occur in 1.21Found to occur in 1.21frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyWeb applications specifically
Description
I have this widget:
SelectableText.rich(
TextSpan(children: [
TextSpan(text: 'foo bar ', style: TextStyle(color: Colors.black)),
TextSpan(text: 'baz qux', style: TextStyle(color: Colors.green)),
]),
textAlign: TextAlign.center,
toolbarOptions: ToolbarOptions(cut: true),
showCursor: true,
)
Expected: selection works
Actual: on web, selection fails with the output below.
There is no error when there is only a single (un-nested) TextSpan as the SelectableText.rich parameter.
Note that when the TextSpan does not have a style (TextSpan style param in constructor is null), there is no problem.
Below, when _cutAndPastedTextStyle/_cutTextStyle/_pastedTextStyle/_defaultTextStyle are null, then selection works. Once they are set to a TextStyle value, selection breaks.
TextSpan _generateTextSpan() {
assert(_words != null);
assert(_words.isNotEmpty);
TextStyle styleForWord(_TranscriptEditorWord word) {
if (word.isCut && word.isPasted) {
return _cutAndPastedTextStyle;
} else if (word.isCut) {
return _cutTextStyle;
} else if (word.isPasted) {
return _pastedTextStyle;
} else {
return _defaultTextStyle;
}
}
final childSpans = _words
.map((transcriptEditingWord) => TextSpan(
text: '${transcriptEditingWord.assetTranscriptWord.word}' +
// Add trailing space after each word, except for the last word.
(transcriptEditingWord == _words.last ? '' : ' '),
style: styleForWord(transcriptEditingWord)))
.toList();
return TextSpan(children: childSpans);
}
cgestes, pulyaevskiy and mykola-dev
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: typographyText rendering, possibly libtxtText rendering, possibly libtxtcustomer: junecustomer: web10found in release: 1.21Found to occur in 1.21Found to occur in 1.21frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyWeb applications specifically