Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix(flutter_desktop): selection in AI chat going missing while scrolling (#7281)

Richard Shiuefc9c152553fc
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
index 067ba95b6b..650840e019 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
@@ -121,21 +121,24 @@ class _ChatContentPage extends StatelessWidget {
child: Align(
alignment: Alignment.topCenter,
child: _wrapConstraints(
- ScrollConfiguration(
- behavior: ScrollConfiguration.of(context)
- .copyWith(scrollbars: false),
- child: Chat(
- chatController:
- context.read<ChatBloc>().chatController,
- user: User(id: userProfile.id.toString()),
- darkTheme: ChatTheme.fromThemeData(Theme.of(context)),
- theme: ChatTheme.fromThemeData(Theme.of(context)),
- builders: Builders(
- inputBuilder: (_) => const SizedBox.shrink(),
- textMessageBuilder: _buildTextMessage,
- chatMessageBuilder: _buildChatMessage,
- scrollToBottomBuilder: _buildScrollToBottom,
- chatAnimatedListBuilder: _buildChatAnimatedList,
+ SelectionArea(
+ child: ScrollConfiguration(
+ behavior: ScrollConfiguration.of(context)
+ .copyWith(scrollbars: false),
+ child: Chat(
+ chatController:
+ context.read<ChatBloc>().chatController,
+ user: User(id: userProfile.id.toString()),
+ darkTheme:
+ ChatTheme.fromThemeData(Theme.of(context)),
+ theme: ChatTheme.fromThemeData(Theme.of(context)),
+ builders: Builders(
+ inputBuilder: (_) => const SizedBox.shrink(),
+ textMessageBuilder: _buildTextMessage,
+ chatMessageBuilder: _buildChatMessage,
+ scrollToBottomBuilder: _buildScrollToBottom,
+ chatAnimatedListBuilder: _buildChatAnimatedList,
+ ),
),
),
),
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/user_text_message.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/user_text_message.dart
index ae0d2863ce..3638ace12f 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/user_text_message.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/user_text_message.dart
@@ -83,7 +83,6 @@ class TextMessageText extends StatelessWidget {
text,
lineHeight: 1.4,
maxLines: null,
- selectable: true,
color: AFThemeExtension.of(context).textColor,
);
}
diff --git a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text.dart b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text.dart
index 76e9eefbc2..360578a4a6 100644
--- a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text.dart
+++ b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text.dart
@@ -15,7 +15,6 @@ class FlowyText extends StatelessWidget {
final TextDecoration? decoration;
final Color? decorationColor;
final double? decorationThickness;
- final bool selectable;
final String? fontFamily;
final List<String>? fallbackFontFamily;
final bool withTooltip;
@@ -41,7 +40,6 @@ class FlowyText extends StatelessWidget {
this.maxLines = 1,
this.decoration,
this.decorationColor,
- this.selectable = false,
this.fontFamily,
this.fallbackFontFamily,
// // https://api.flutter.dev/flutter/painting/TextStyle/height.html
@@ -63,7 +61,6 @@ class FlowyText extends StatelessWidget {
this.maxLines = 1,
this.decoration,
this.decorationColor,
- this.selectable = false,
this.fontFamily,
this.fallbackFontFamily,
this.lineHeight,
@@ -86,7 +83,6 @@ class FlowyText extends StatelessWidget {
this.maxLines = 1,
this.decoration,
this.decorationColor,
- this.selectable = false,
this.fontFamily,
this.fallbackFontFamily,
this.lineHeight,
@@ -108,7 +104,6 @@ class FlowyText extends StatelessWidget {
this.maxLines = 1,
this.decoration,
this.decorationColor,
- this.selectable = false,
this.fontFamily,
this.fallbackFontFamily,
this.lineHeight,
@@ -130,7 +125,6 @@ class FlowyText extends StatelessWidget {
this.maxLines = 1,
this.decoration,
this.decorationColor,
- this.selectable = false,
this.fontFamily,
this.fallbackFontFamily,
this.lineHeight,
@@ -153,7 +147,6 @@ class FlowyText extends StatelessWidget {
this.maxLines = 1,
this.decoration,
this.decorationColor,
- this.selectable = false,
this.lineHeight,
this.withTooltip = false,
this.strutStyle = const StrutStyle(forceStrutHeight: true),
@@ -211,32 +204,21 @@ class FlowyText extends StatelessWidget {
: null,
);
- if (selectable) {
- child = IntrinsicHeight(
- child: SelectableText(
- text,
- maxLines: maxLines,
- textAlign: textAlign,
- style: textStyle,
- ),
- );
- } else {
- child = Text(
- text,
- maxLines: maxLines,
- textAlign: textAlign,
- overflow: overflow ?? TextOverflow.clip,
- style: textStyle,
- strutStyle: !isEmoji || (isEmoji && optimizeEmojiAlign)
- ? StrutStyle.fromTextStyle(
- textStyle,
- forceStrutHeight: true,
- leadingDistribution: TextLeadingDistribution.even,
- height: lineHeight,
- )
- : null,
- );
- }
+ child = Text(
+ text,
+ maxLines: maxLines,
+ textAlign: textAlign,
+ overflow: overflow ?? TextOverflow.clip,
+ style: textStyle,
+ strutStyle: !isEmoji || (isEmoji && optimizeEmojiAlign)
+ ? StrutStyle.fromTextStyle(
+ textStyle,
+ forceStrutHeight: true,
+ leadingDistribution: TextLeadingDistribution.even,
+ height: lineHeight,
+ )
+ : null,
+ );
if (withTooltip) {
child = FlowyTooltip(