Skip to content

Commit 06bbc06

Browse files
authored
fix: focus is clickable if text field is being edited (#3020)
1 parent f6edd4b commit 06bbc06

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import 'package:appflowy/workspace/application/settings/prelude.dart';
2+
import 'package:appflowy/workspace/presentation/settings/widgets/settings_appearance_view.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:flutter_test/flutter_test.dart';
5+
import 'package:integration_test/integration_test.dart';
6+
import 'util/util.dart';
7+
8+
void main() {
9+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
10+
11+
group('appearance settings tests', () {
12+
testWidgets('after editing text field, button should be able to be clicked',
13+
(tester) async {
14+
await tester.initializeAppFlowy();
15+
16+
await tester.tapGoButton();
17+
tester.expectToSeeHomePage();
18+
await tester.openSettings();
19+
20+
await tester.openSettingsPage(SettingsPage.appearance);
21+
22+
final dropDown = find.byKey(ThemeFontFamilySetting.popoverKey);
23+
await tester.tap(dropDown);
24+
await tester.pumpAndSettle();
25+
26+
final textField = find.byKey(ThemeFontFamilySetting.textFieldKey);
27+
await tester.tap(textField);
28+
await tester.pumpAndSettle();
29+
30+
await tester.enterText(textField, 'Abel');
31+
await tester.pumpAndSettle();
32+
final fontFamilyButton = find.byKey(const Key('Abel'));
33+
34+
expect(fontFamilyButton, findsOneWidget);
35+
await tester.tap(fontFamilyButton);
36+
await tester.pumpAndSettle();
37+
38+
// just switch the page and verify that the font family was set after that
39+
await tester.openSettingsPage(SettingsPage.files);
40+
await tester.openSettingsPage(SettingsPage.appearance);
41+
42+
expect(find.textContaining('Abel'), findsOneWidget);
43+
});
44+
});
45+
}

frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_appearance_view.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ class ThemeFontFamilySetting extends StatefulWidget {
286286
});
287287

288288
final String currentFontFamily;
289+
static Key textFieldKey = const Key('FontFamilyTextField');
290+
static Key popoverKey = const Key('FontFamilyPopover');
289291

290292
@override
291293
State<ThemeFontFamilySetting> createState() => _ThemeFontFamilySettingState();
@@ -298,6 +300,7 @@ class _ThemeFontFamilySettingState extends State<ThemeFontFamilySetting> {
298300
@override
299301
Widget build(BuildContext context) {
300302
return ThemeSettingDropDown(
303+
popoverKey: ThemeFontFamilySetting.popoverKey,
301304
label: LocaleKeys.settings_appearance_fontFamily_label.tr(),
302305
currentValue: parseFontFamilyName(widget.currentFontFamily),
303306
onClose: () {
@@ -310,6 +313,7 @@ class _ThemeFontFamilySettingState extends State<ThemeFontFamilySetting> {
310313
padding: const EdgeInsets.only(right: 8),
311314
sliver: SliverToBoxAdapter(
312315
child: FlowyTextField(
316+
key: ThemeFontFamilySetting.textFieldKey,
313317
hintText: LocaleKeys.settings_appearance_fontFamily_search.tr(),
314318
autoFocus: false,
315319
debounceDuration: const Duration(milliseconds: 300),
@@ -364,6 +368,8 @@ class _ThemeFontFamilySettingState extends State<ThemeFontFamilySetting> {
364368
key: UniqueKey(),
365369
height: 32,
366370
child: FlowyButton(
371+
key: Key(buttonFontFamily),
372+
onHover: (_) => FocusScope.of(context).unfocus(),
367373
text: FlowyText.medium(
368374
parseFontFamilyName(style.fontFamily!),
369375
fontFamily: style.fontFamily!,
@@ -394,11 +400,13 @@ class ThemeSettingDropDown extends StatefulWidget {
394400
required this.label,
395401
required this.currentValue,
396402
required this.popupBuilder,
403+
this.popoverKey,
397404
this.onClose,
398405
});
399406

400407
final String label;
401408
final String currentValue;
409+
final Key? popoverKey;
402410
final Widget Function(BuildContext) popupBuilder;
403411
final void Function()? onClose;
404412

@@ -418,6 +426,7 @@ class _ThemeSettingDropDownState extends State<ThemeSettingDropDown> {
418426
),
419427
),
420428
AppFlowyPopover(
429+
key: widget.popoverKey,
421430
direction: PopoverDirection.bottomWithRightAligned,
422431
popupBuilder: widget.popupBuilder,
423432
constraints: const BoxConstraints(

0 commit comments

Comments
 (0)