Skip to content

Commit f655581

Browse files
committed
fix: autofocus after creating a new option
1 parent 529ede5 commit f655581

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,19 @@ class SelectOptionCellEditorBloc
103103
void _filterOption(String optionName, Emitter<SelectOptionEditorState> emit) {
104104
final _MakeOptionResult result =
105105
_makeOptions(Some(optionName), state.allOptions);
106-
emit(state.copyWith(
107-
filter: Some(optionName),
108-
options: result.options,
109-
createOption: result.createOption,
110-
));
106+
if (optionName.isEmpty) {
107+
emit(state.copyWith(
108+
filter: Some(optionName),
109+
options: result.options,
110+
createOption: none(),
111+
));
112+
} else {
113+
emit(state.copyWith(
114+
filter: Some(optionName),
115+
options: result.options,
116+
createOption: result.createOption,
117+
));
118+
}
111119
}
112120

113121
void _loadOptions() {

frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/extension.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,7 @@ class SelectOptionTag extends StatelessWidget {
100100
backgroundColor: color,
101101
labelPadding: const EdgeInsets.symmetric(horizontal: 6),
102102
selected: true,
103-
onSelected: (_) {
104-
if (onSelected != null) {
105-
onSelected!();
106-
}
107-
},
103+
onSelected: (_) => onSelected?.call(),
108104
);
109105
}
110106
}

frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/select_option_editor.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import '../../header/type_option/select_option_editor.dart';
2222
import 'extension.dart';
2323
import 'text_field.dart';
2424

25-
const double _editorPannelWidth = 300;
25+
const double _editorPanelWidth = 300;
2626

2727
class SelectOptionCellEditor extends StatelessWidget with FlowyOverlayDelegate {
2828
final GridSelectOptionCellController cellController;
@@ -72,8 +72,8 @@ class SelectOptionCellEditor extends StatelessWidget with FlowyOverlayDelegate {
7272
//
7373
FlowyOverlay.of(context).insertWithAnchor(
7474
widget: OverlayContainer(
75-
constraints: BoxConstraints.loose(const Size(_editorPannelWidth, 300)),
76-
child: SizedBox(width: _editorPannelWidth, child: editor),
75+
constraints: BoxConstraints.loose(const Size(_editorPanelWidth, 300)),
76+
child: SizedBox(width: _editorPanelWidth, child: editor),
7777
),
7878
identifier: SelectOptionCellEditor.identifier(),
7979
anchorContext: context,
@@ -158,7 +158,7 @@ class _TextField extends StatelessWidget {
158158
child: SelectOptionTextField(
159159
options: state.options,
160160
selectedOptionMap: optionMap,
161-
distanceToText: _editorPannelWidth * 0.7,
161+
distanceToText: _editorPanelWidth * 0.7,
162162
tagController: _tagController,
163163
onClick: () => FlowyOverlay.of(context)
164164
.remove(SelectOptionTypeOptionEditor.identifier),

frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/select_option_cell/text_field.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ class SelectOptionTextField extends StatelessWidget {
3232
required this.onNewTag,
3333
required this.newText,
3434
this.onClick,
35-
TextEditingController? controller,
35+
TextEditingController? textController,
3636
FocusNode? focusNode,
3737
Key? key,
38-
}) : _controller = controller ?? TextEditingController(),
38+
}) : _controller = textController ?? TextEditingController(),
3939
_focusNode = focusNode ?? FocusNode(),
4040
super(key: key);
4141

@@ -48,7 +48,7 @@ class SelectOptionTextField extends StatelessWidget {
4848
textfieldTagsController: tagController,
4949
initialTags: selectedOptionMap.keys.toList(),
5050
focusNode: _focusNode,
51-
textSeparators: const [' ', ','],
51+
textSeparators: const [','],
5252
inputfieldBuilder: (BuildContext context, editController, focusNode,
5353
error, onChanged, onSubmitted) {
5454
return ((context, sc, tags, onTagDelegate) {
@@ -70,6 +70,7 @@ class SelectOptionTextField extends StatelessWidget {
7070

7171
if (text.isNotEmpty) {
7272
onNewTag(text);
73+
focusNode.requestFocus();
7374
}
7475
},
7576
maxLines: 1,

0 commit comments

Comments
 (0)