Skip to content

Commit

Permalink
fix(flutter_desktop): selection in AI chat going missing while scroll…
Browse files Browse the repository at this point in the history
…ing (#7281)
  • Loading branch information
richardshiue authored Feb 7, 2025
1 parent 00cdee8 commit fc9c152
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 49 deletions.
33 changes: 18 additions & 15 deletions frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class TextMessageText extends StatelessWidget {
text,
lineHeight: 1.4,
maxLines: null,
selectable: true,
color: AFThemeExtension.of(context).textColor,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -63,7 +61,6 @@ class FlowyText extends StatelessWidget {
this.maxLines = 1,
this.decoration,
this.decorationColor,
this.selectable = false,
this.fontFamily,
this.fallbackFontFamily,
this.lineHeight,
Expand All @@ -86,7 +83,6 @@ class FlowyText extends StatelessWidget {
this.maxLines = 1,
this.decoration,
this.decorationColor,
this.selectable = false,
this.fontFamily,
this.fallbackFontFamily,
this.lineHeight,
Expand All @@ -108,7 +104,6 @@ class FlowyText extends StatelessWidget {
this.maxLines = 1,
this.decoration,
this.decorationColor,
this.selectable = false,
this.fontFamily,
this.fallbackFontFamily,
this.lineHeight,
Expand All @@ -130,7 +125,6 @@ class FlowyText extends StatelessWidget {
this.maxLines = 1,
this.decoration,
this.decorationColor,
this.selectable = false,
this.fontFamily,
this.fallbackFontFamily,
this.lineHeight,
Expand All @@ -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),
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit fc9c152

Please sign in to comment.