From e33d7de6d419d682641770943188adfb6b146efa Mon Sep 17 00:00:00 2001 From: ZhuchkaTriplesix Date: Sat, 17 Oct 2026 07:11:06 +0300 Subject: [PATCH] ui(settings): prevent horizontal overflow in shortcut keycaps and add mono fallback (#1652) --- .../preferences_shortcuts_section.dart | 41 ++++++++++++------- .../preferences_shortcuts_section_test.dart | 35 ++++++++++++++++ 2 files changed, 61 insertions(+), 15 deletions(-) diff --git a/lib/features/settings/preferences_shortcuts_section.dart b/lib/features/settings/preferences_shortcuts_section.dart index 67da3443..ca53338b 100644 --- a/lib/features/settings/preferences_shortcuts_section.dart +++ b/lib/features/settings/preferences_shortcuts_section.dart @@ -381,30 +381,40 @@ class _PreferencesShortcutsSectionState ), ), const material.SizedBox(width: 12), - material.Row( - mainAxisSize: material.MainAxisSize.min, - children: [ - for (var c = 0; c < item.allKeys.length; c++) ...[ - if (c > 0) - material.Padding( - padding: const material.EdgeInsets.symmetric(horizontal: 6), - child: const Text('or').muted().xSmall(), - ), - ..._keycaps(item.allKeys[c], theme), + material.Flexible( + child: material.Wrap( + alignment: material.WrapAlignment.end, + crossAxisAlignment: material.WrapCrossAlignment.center, + spacing: 4, + runSpacing: 4, + children: [ + for (var c = 0; c < item.allKeys.length; c++) ...[ + if (c > 0) + material.Padding( + padding: const material.EdgeInsets.symmetric(horizontal: 4), + child: const Text('or').muted().xSmall(), + ), + ..._keycaps(context, item.allKeys[c], theme), + ], ], - ], + ), ), ], ), ); } - List _keycaps(List keys, ThemeData theme) { + List _keycaps( + BuildContext context, + List keys, + ThemeData theme, + ) { + final wb = context.workbenchOrDefault; return [ for (var j = 0; j < keys.length; j++) ...[ if (j > 0) material.Padding( - padding: const material.EdgeInsets.symmetric(horizontal: 3), + padding: const material.EdgeInsets.symmetric(horizontal: 2), child: const Text('+').muted().xSmall(), ), material.Container( @@ -413,14 +423,14 @@ class _PreferencesShortcutsSectionState vertical: 3, ), decoration: material.BoxDecoration( - color: theme.colorScheme.background, + color: wb.surface, borderRadius: material.BorderRadius.circular(4), border: material.Border.all( color: theme.colorScheme.border.withValues(alpha: 0.4), ), boxShadow: [ material.BoxShadow( - color: material.Colors.black.withValues(alpha: 0.08), + color: wb.shadow.withValues(alpha: 0.12), offset: const material.Offset(0, 1), blurRadius: 1, ), @@ -430,6 +440,7 @@ class _PreferencesShortcutsSectionState keys[j], style: material.TextStyle( fontFamily: QueryaTypography.mono, + fontFamilyFallback: QueryaTypography.monoFontFamilyFallback, fontSize: 11, fontWeight: material.FontWeight.w600, color: theme.colorScheme.foreground, diff --git a/test/features/settings/preferences_shortcuts_section_test.dart b/test/features/settings/preferences_shortcuts_section_test.dart index 063abba2..4cf0f942 100644 --- a/test/features/settings/preferences_shortcuts_section_test.dart +++ b/test/features/settings/preferences_shortcuts_section_test.dart @@ -1,8 +1,12 @@ import 'package:flutter/material.dart' as material; import 'package:flutter_test/flutter_test.dart'; +import 'package:querya_desktop/core/theme/querya_theme.dart'; +import 'package:querya_desktop/core/theme/querya_typography.dart'; import 'package:querya_desktop/features/settings/preferences_shortcuts_section.dart'; import 'package:querya_desktop/shared/widgets/widgets.dart'; +import '../../support/querya_theme_test_shell.dart'; + void main() { Widget buildTestWidget({String searchQuery = ''}) { return ShadcnApp( @@ -104,5 +108,36 @@ void main() { expect(find.text('No shortcuts match "xyzunknown"'), findsOneWidget); expect(find.text('Execute query / selection'), findsNothing); }); + + testWidgets('uses mono font fallback and does not overflow under narrow constraints (#1652)', + (tester) async { + tester.view.physicalSize = const material.Size(320, 600); + tester.view.devicePixelRatio = 1.0; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + + await tester.pumpWidget( + queryaThemeTestShell( + data: QueryaTheme.darkDefault, + child: const material.Scaffold( + body: material.SingleChildScrollView( + child: PreferencesShortcutsSection(), + ), + ), + ), + ); + await tester.pumpAndSettle(); + + // No RenderFlex overflow should occur. + expect(tester.takeException(), isNull); + + // Verify mono font and fallback stack on keycaps. + final f5Key = tester.widget(find.text('F5').first); + expect(f5Key.style?.fontFamily, QueryaTypography.mono); + expect( + f5Key.style?.fontFamilyFallback, + QueryaTypography.monoFontFamilyFallback, + ); + }); }); }