diff --git a/lib/pages/common/publish/common_rich_text_pub_page.dart b/lib/pages/common/publish/common_rich_text_pub_page.dart index a9410f2c..c8366a2c 100644 --- a/lib/pages/common/publish/common_rich_text_pub_page.dart +++ b/lib/pages/common/publish/common_rich_text_pub_page.dart @@ -327,7 +327,7 @@ abstract class CommonRichTextPubPageState editController ..syncRichText(delta) - ..value = newValue.copyWith(selection: editController.newSelection); + ..value = newValue; } else { editController.value = TextEditingValue( text: text, diff --git a/lib/pages/dynamics_create/view.dart b/lib/pages/dynamics_create/view.dart index 678c0c5e..d8d605ba 100644 --- a/lib/pages/dynamics_create/view.dart +++ b/lib/pages/dynamics_create/view.dart @@ -564,11 +564,15 @@ class _CreateDynPanelState extends CommonRichTextPubPageState { ); if (voteInfo != null) { if (voteItem != null) { + final range = voteItem.range; + final text = ' ${voteInfo.title} '; + final selection = TextSelection.collapsed( + offset: range.start + text.length); final delta = RichTextEditingDeltaReplacement( oldText: editController.text, - replacementText: ' ${voteInfo.title} ', - replacedRange: voteItem.range, - selection: editController.selection, + replacementText: text, + replacedRange: range, + selection: selection, composing: TextRange.empty, type: RichTextType.vote, id: voteInfo.voteId.toString(), @@ -577,9 +581,7 @@ class _CreateDynPanelState extends CommonRichTextPubPageState { final newValue = delta.apply(editController.value); editController ..syncRichText(delta) - ..value = newValue.copyWith( - selection: editController.newSelection, - ); + ..value = newValue; } else { onInsertText( '我发起了一个投票',