Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: arrow keys on field name text field (#3162)
Richard Shiuee9f31ea0f87f
diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_editor.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_editor.dartindex 5c1be5911c..57cca6acba 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_editor.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/field_editor.dart@@ -2,7 +2,6 @@ import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/plugins/database_view/application/field/field_editor_bloc.dart';import 'package:appflowy/plugins/database_view/application/field/type_option/type_option_context.dart';import 'package:appflowy_popover/appflowy_popover.dart';-import 'package:dartz/dartz.dart' show none;import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/style_widget/button.dart';@@ -164,6 +163,8 @@ class _FieldNameTextFieldState extends State<FieldNameTextField> {@overridevoid initState() {+ super.initState();+focusNode.addListener(() {if (focusNode.hasFocus) {widget.popoverMutex.close();@@ -175,39 +176,28 @@ class _FieldNameTextFieldState extends State<FieldNameTextField> {focusNode.unfocus();}});-- super.initState();}@overrideWidget build(BuildContext context) {- return BlocListener<FieldEditorBloc, FieldEditorState>(- listenWhen: (p, c) => p.field == none(),- listener: (context, state) {- textController.text = state.name;- focusNode.requestFocus();+ return BlocBuilder<FieldEditorBloc, FieldEditorState>(+ builder: (context, state) {+ return Padding(+ padding: const EdgeInsets.symmetric(horizontal: 12.0),+ child: FlowyTextField(+ focusNode: focusNode,+ controller: textController,+ onSubmitted: (String _) => PopoverContainer.of(context).close(),+ text: state.name,+ errorText: state.errorText.isEmpty ? null : state.errorText,+ onChanged: (newName) {+ context+ .read<FieldEditorBloc>()+ .add(FieldEditorEvent.updateName(newName));+ },+ ),+ );},- child: BlocBuilder<FieldEditorBloc, FieldEditorState>(- buildWhen: (previous, current) =>- previous.errorText != current.errorText,- builder: (context, state) {- return Padding(- padding: const EdgeInsets.symmetric(horizontal: 12.0),- child: FlowyTextField(- focusNode: focusNode,- controller: textController,- onSubmitted: (String _) => PopoverContainer.of(context).close(),- text: state.name,- errorText: state.errorText.isEmpty ? null : state.errorText,- onChanged: (newName) {- context- .read<FieldEditorBloc>()- .add(FieldEditorEvent.updateName(newName));- },- ),- );- },- ),);}}diff --git a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text_field.dart b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text_field.dartindex be61f491dd..562f1f403c 100644--- a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text_field.dart+++ b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text_field.dart@@ -54,15 +54,13 @@ class FlowyTextFieldState extends State<FlowyTextField> {focusNode = widget.focusNode ?? FocusNode();focusNode.addListener(notifyDidEndEditing);- if (widget.controller != null) {- controller = widget.controller!;- } else {- controller = TextEditingController();- controller.text = widget.text;- }+ controller = widget.controller ?? TextEditingController();+ controller.text = widget.text;if (widget.autoFocus) {WidgetsBinding.instance.addPostFrameCallback((_) {focusNode.requestFocus();+ controller.selection = TextSelection.fromPosition(+ TextPosition(offset: controller.text.length));});}super.initState();