fix: click enter to submit the text content (#1537)

Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
Nathan.fooo 2022-12-05 17:17:33 +08:00 committed by GitHub
parent a2f9ca2f28
commit 64ee3140a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 25 deletions

View File

@ -37,7 +37,6 @@ class GridTextCell extends GridCellWidget {
class _GridTextCellState extends GridFocusNodeCellState<GridTextCell> {
late TextCellBloc _cellBloc;
late TextEditingController _controller;
Timer? _delayOperation;
@override
void initState() {
@ -66,7 +65,9 @@ class _GridTextCellState extends GridFocusNodeCellState<GridTextCell> {
child: TextField(
controller: _controller,
focusNode: focusNode,
onChanged: (value) => focusChanged(),
onSubmitted: (text) => _cellBloc.add(
TextCellEvent.updateText(text),
),
onEditingComplete: () => focusNode.unfocus(),
maxLines: null,
style: Theme.of(context).textTheme.bodyMedium,
@ -87,24 +88,10 @@ class _GridTextCellState extends GridFocusNodeCellState<GridTextCell> {
@override
Future<void> dispose() async {
_delayOperation = null;
_cellBloc.close();
super.dispose();
}
@override
Future<void> focusChanged() async {
if (mounted) {
_delayOperation?.cancel();
_delayOperation = Timer(const Duration(milliseconds: 30), () {
if (_cellBloc.isClosed == false &&
_controller.text != _cellBloc.state.content) {
_cellBloc.add(TextCellEvent.updateText(_controller.text));
}
});
}
}
@override
String? onCopy() => _cellBloc.state.content;

View File

@ -167,12 +167,3 @@ class _SelectOptionFilterEditorState extends State<SelectOptionFilterEditor> {
);
}
}
class _FilterPannel extends StatelessWidget {
const _FilterPannel({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container();
}
}