mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: focus is clickable if text field is being edited (#3020)
This commit is contained in:
parent
f6edd4b32b
commit
06bbc06fff
@ -0,0 +1,45 @@
|
||||
import 'package:appflowy/workspace/application/settings/prelude.dart';
|
||||
import 'package:appflowy/workspace/presentation/settings/widgets/settings_appearance_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import 'util/util.dart';
|
||||
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('appearance settings tests', () {
|
||||
testWidgets('after editing text field, button should be able to be clicked',
|
||||
(tester) async {
|
||||
await tester.initializeAppFlowy();
|
||||
|
||||
await tester.tapGoButton();
|
||||
tester.expectToSeeHomePage();
|
||||
await tester.openSettings();
|
||||
|
||||
await tester.openSettingsPage(SettingsPage.appearance);
|
||||
|
||||
final dropDown = find.byKey(ThemeFontFamilySetting.popoverKey);
|
||||
await tester.tap(dropDown);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final textField = find.byKey(ThemeFontFamilySetting.textFieldKey);
|
||||
await tester.tap(textField);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.enterText(textField, 'Abel');
|
||||
await tester.pumpAndSettle();
|
||||
final fontFamilyButton = find.byKey(const Key('Abel'));
|
||||
|
||||
expect(fontFamilyButton, findsOneWidget);
|
||||
await tester.tap(fontFamilyButton);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// just switch the page and verify that the font family was set after that
|
||||
await tester.openSettingsPage(SettingsPage.files);
|
||||
await tester.openSettingsPage(SettingsPage.appearance);
|
||||
|
||||
expect(find.textContaining('Abel'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
@ -286,6 +286,8 @@ class ThemeFontFamilySetting extends StatefulWidget {
|
||||
});
|
||||
|
||||
final String currentFontFamily;
|
||||
static Key textFieldKey = const Key('FontFamilyTextField');
|
||||
static Key popoverKey = const Key('FontFamilyPopover');
|
||||
|
||||
@override
|
||||
State<ThemeFontFamilySetting> createState() => _ThemeFontFamilySettingState();
|
||||
@ -298,6 +300,7 @@ class _ThemeFontFamilySettingState extends State<ThemeFontFamilySetting> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ThemeSettingDropDown(
|
||||
popoverKey: ThemeFontFamilySetting.popoverKey,
|
||||
label: LocaleKeys.settings_appearance_fontFamily_label.tr(),
|
||||
currentValue: parseFontFamilyName(widget.currentFontFamily),
|
||||
onClose: () {
|
||||
@ -310,6 +313,7 @@ class _ThemeFontFamilySettingState extends State<ThemeFontFamilySetting> {
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: FlowyTextField(
|
||||
key: ThemeFontFamilySetting.textFieldKey,
|
||||
hintText: LocaleKeys.settings_appearance_fontFamily_search.tr(),
|
||||
autoFocus: false,
|
||||
debounceDuration: const Duration(milliseconds: 300),
|
||||
@ -364,6 +368,8 @@ class _ThemeFontFamilySettingState extends State<ThemeFontFamilySetting> {
|
||||
key: UniqueKey(),
|
||||
height: 32,
|
||||
child: FlowyButton(
|
||||
key: Key(buttonFontFamily),
|
||||
onHover: (_) => FocusScope.of(context).unfocus(),
|
||||
text: FlowyText.medium(
|
||||
parseFontFamilyName(style.fontFamily!),
|
||||
fontFamily: style.fontFamily!,
|
||||
@ -394,11 +400,13 @@ class ThemeSettingDropDown extends StatefulWidget {
|
||||
required this.label,
|
||||
required this.currentValue,
|
||||
required this.popupBuilder,
|
||||
this.popoverKey,
|
||||
this.onClose,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String currentValue;
|
||||
final Key? popoverKey;
|
||||
final Widget Function(BuildContext) popupBuilder;
|
||||
final void Function()? onClose;
|
||||
|
||||
@ -418,6 +426,7 @@ class _ThemeSettingDropDownState extends State<ThemeSettingDropDown> {
|
||||
),
|
||||
),
|
||||
AppFlowyPopover(
|
||||
key: widget.popoverKey,
|
||||
direction: PopoverDirection.bottomWithRightAligned,
|
||||
popupBuilder: widget.popupBuilder,
|
||||
constraints: const BoxConstraints(
|
||||
|
Loading…
Reference in New Issue
Block a user