From 3f4215a95575cd14cea526b54e564b5f03e12cee Mon Sep 17 00:00:00 2001 From: zjs81 Date: Fri, 20 Nov 2026 18:13:53 -0700 Subject: [PATCH] Keep a long reply region chip inside the composer quote --- lib/screens/channel_chat_screen.dart | 2 + lib/widgets/chat_composer.dart | 63 ++++++++++++++++------------ test/widgets/chat_composer_test.dart | 8 ++++ 3 files changed, 47 insertions(+), 26 deletions(-) diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index 99a214c7..02aedafa 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -2670,6 +2670,8 @@ class _ChannelChatScreenState extends State { ), child: Text( context.l10n.channels_regionSetTo(replyRegion!), + maxLines: 1, + overflow: TextOverflow.ellipsis, style: MeshTheme.mono( fontSize: 12 * textScale, diff --git a/lib/widgets/chat_composer.dart b/lib/widgets/chat_composer.dart index 8141e676..4f59efaa 100644 --- a/lib/widgets/chat_composer.dart +++ b/lib/widgets/chat_composer.dart @@ -468,34 +468,45 @@ class ChatComposerQuote extends StatelessWidget { ), child: Padding( padding: const EdgeInsetsDirectional.fromSTEB(10, 6, 0, 6), - child: Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - title, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: Theme.of(context).textTheme.bodyMedium?.copyWith( - fontWeight: FontWeight.w700, - color: accent, + child: LayoutBuilder( + builder: (context, constraints) => Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + title, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w700, + color: accent, + ), ), - ), - content, - ], + content, + ], + ), ), - ), - ?trailing, - IconButton( - icon: const Icon(Icons.close), - tooltip: dismissTooltip, - color: scheme.onSurfaceVariant, - onPressed: onDismiss, - ), - ], + // The quote shares its row with Send, so a long trailing + // control (a region chip) must not squeeze out the message + // or the dismiss button. + if (trailing != null) + ConstrainedBox( + constraints: BoxConstraints( + maxWidth: constraints.maxWidth * 0.4, + ), + child: trailing, + ), + IconButton( + icon: const Icon(Icons.close), + tooltip: dismissTooltip, + color: scheme.onSurfaceVariant, + onPressed: onDismiss, + ), + ], + ), ), ), ), diff --git a/test/widgets/chat_composer_test.dart b/test/widgets/chat_composer_test.dart index e75a590c..dd56e995 100644 --- a/test/widgets/chat_composer_test.dart +++ b/test/widgets/chat_composer_test.dart @@ -479,10 +479,18 @@ void main() { ), onDismiss: () {}, dismissTooltip: _l10n.chat_cancelReply, + // A long region chip, as a channel reply shows. + trailing: Text( + _l10n.channels_regionSetTo('north-west-valley'), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), ), ), ); await tester.pumpAndSettle(); + expect(tester.takeException(), isNull); + expect(find.byTooltip(_l10n.chat_cancelReply), findsOneWidget); await _type(tester, 'a' * 19); expect(tester.takeException(), isNull);