mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: arrow keys on field name text field (#3162)
This commit is contained in:
@ -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/field_editor_bloc.dart';
|
||||||
import 'package:appflowy/plugins/database_view/application/field/type_option/type_option_context.dart';
|
import 'package:appflowy/plugins/database_view/application/field/type_option/type_option_context.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
import 'package:dartz/dartz.dart' show none;
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
|
||||||
import 'package:flowy_infra_ui/style_widget/button.dart';
|
import 'package:flowy_infra_ui/style_widget/button.dart';
|
||||||
@ -164,6 +163,8 @@ class _FieldNameTextFieldState extends State<FieldNameTextField> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
focusNode.addListener(() {
|
focusNode.addListener(() {
|
||||||
if (focusNode.hasFocus) {
|
if (focusNode.hasFocus) {
|
||||||
widget.popoverMutex.close();
|
widget.popoverMutex.close();
|
||||||
@ -175,21 +176,11 @@ class _FieldNameTextFieldState extends State<FieldNameTextField> {
|
|||||||
focusNode.unfocus();
|
focusNode.unfocus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
super.initState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocListener<FieldEditorBloc, FieldEditorState>(
|
return BlocBuilder<FieldEditorBloc, FieldEditorState>(
|
||||||
listenWhen: (p, c) => p.field == none(),
|
|
||||||
listener: (context, state) {
|
|
||||||
textController.text = state.name;
|
|
||||||
focusNode.requestFocus();
|
|
||||||
},
|
|
||||||
child: BlocBuilder<FieldEditorBloc, FieldEditorState>(
|
|
||||||
buildWhen: (previous, current) =>
|
|
||||||
previous.errorText != current.errorText,
|
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||||
@ -207,7 +198,6 @@ class _FieldNameTextFieldState extends State<FieldNameTextField> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,15 +54,13 @@ class FlowyTextFieldState extends State<FlowyTextField> {
|
|||||||
focusNode = widget.focusNode ?? FocusNode();
|
focusNode = widget.focusNode ?? FocusNode();
|
||||||
focusNode.addListener(notifyDidEndEditing);
|
focusNode.addListener(notifyDidEndEditing);
|
||||||
|
|
||||||
if (widget.controller != null) {
|
controller = widget.controller ?? TextEditingController();
|
||||||
controller = widget.controller!;
|
|
||||||
} else {
|
|
||||||
controller = TextEditingController();
|
|
||||||
controller.text = widget.text;
|
controller.text = widget.text;
|
||||||
}
|
|
||||||
if (widget.autoFocus) {
|
if (widget.autoFocus) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
focusNode.requestFocus();
|
focusNode.requestFocus();
|
||||||
|
controller.selection = TextSelection.fromPosition(
|
||||||
|
TextPosition(offset: controller.text.length));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
super.initState();
|
super.initState();
|
||||||
|
Reference in New Issue
Block a user