From 3686351592b1b8a707544e3739d213b2d6433452 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 29 Aug 2022 10:08:44 +0800 Subject: [PATCH] fix: #918 could not update the link sometimes --- .../lib/src/render/rich_text/flowy_rich_text.dart | 13 ++++++++++++- .../test/render/rich_text/checkbox_text_test.dart | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/flowy_rich_text.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/flowy_rich_text.dart index 39f484c23f..884a8bbe12 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/flowy_rich_text.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/flowy_rich_text.dart @@ -42,7 +42,7 @@ class FlowyRichText extends StatefulWidget { } class _FlowyRichTextState extends State with Selectable { - final _textKey = GlobalKey(); + var _textKey = GlobalKey(); final _placeholderTextKey = GlobalKey(); final _lineHeight = 1.5; @@ -53,6 +53,17 @@ class _FlowyRichTextState extends State with Selectable { RenderParagraph get _placeholderRenderParagraph => _placeholderTextKey.currentContext?.findRenderObject() as RenderParagraph; + @override + void didUpdateWidget(covariant FlowyRichText oldWidget) { + super.didUpdateWidget(oldWidget); + + // https://github.com/flutter/flutter/issues/110342 + if (_textKey.currentWidget is RichText) { + // Force refresh the RichText widget. + _textKey = GlobalKey(); + } + } + @override Widget build(BuildContext context) { return _buildRichText(context); diff --git a/frontend/app_flowy/packages/appflowy_editor/test/render/rich_text/checkbox_text_test.dart b/frontend/app_flowy/packages/appflowy_editor/test/render/rich_text/checkbox_text_test.dart index f039c227d9..afd89ddee9 100644 --- a/frontend/app_flowy/packages/appflowy_editor/test/render/rich_text/checkbox_text_test.dart +++ b/frontend/app_flowy/packages/appflowy_editor/test/render/rich_text/checkbox_text_test.dart @@ -10,8 +10,8 @@ void main() async { TestWidgetsFlutterBinding.ensureInitialized(); }); - group('delete_text_handler.dart', () { - testWidgets('Presses backspace key in empty document', (tester) async { + group('checkbox_text_handler.dart', () { + testWidgets('Click checkbox icon', (tester) async { // Before // // [BIUS]Welcome to Appflowy 😁[BIUS]