mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: autofocus after creating a new option
This commit is contained in:
parent
af813806f1
commit
c7db59c99b
@ -103,11 +103,19 @@ class SelectOptionCellEditorBloc
|
|||||||
void _filterOption(String optionName, Emitter<SelectOptionEditorState> emit) {
|
void _filterOption(String optionName, Emitter<SelectOptionEditorState> emit) {
|
||||||
final _MakeOptionResult result =
|
final _MakeOptionResult result =
|
||||||
_makeOptions(Some(optionName), state.allOptions);
|
_makeOptions(Some(optionName), state.allOptions);
|
||||||
emit(state.copyWith(
|
if (optionName.isEmpty) {
|
||||||
filter: Some(optionName),
|
emit(state.copyWith(
|
||||||
options: result.options,
|
filter: Some(optionName),
|
||||||
createOption: result.createOption,
|
options: result.options,
|
||||||
));
|
createOption: none(),
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
emit(state.copyWith(
|
||||||
|
filter: Some(optionName),
|
||||||
|
options: result.options,
|
||||||
|
createOption: result.createOption,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _loadOptions() {
|
void _loadOptions() {
|
||||||
|
@ -100,11 +100,7 @@ class SelectOptionTag extends StatelessWidget {
|
|||||||
backgroundColor: color,
|
backgroundColor: color,
|
||||||
labelPadding: const EdgeInsets.symmetric(horizontal: 6),
|
labelPadding: const EdgeInsets.symmetric(horizontal: 6),
|
||||||
selected: true,
|
selected: true,
|
||||||
onSelected: (_) {
|
onSelected: (_) => onSelected?.call(),
|
||||||
if (onSelected != null) {
|
|
||||||
onSelected!();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import '../../header/type_option/select_option_editor.dart';
|
|||||||
import 'extension.dart';
|
import 'extension.dart';
|
||||||
import 'text_field.dart';
|
import 'text_field.dart';
|
||||||
|
|
||||||
const double _editorPannelWidth = 300;
|
const double _editorPanelWidth = 300;
|
||||||
|
|
||||||
class SelectOptionCellEditor extends StatelessWidget with FlowyOverlayDelegate {
|
class SelectOptionCellEditor extends StatelessWidget with FlowyOverlayDelegate {
|
||||||
final GridSelectOptionCellController cellController;
|
final GridSelectOptionCellController cellController;
|
||||||
@ -75,8 +75,8 @@ class SelectOptionCellEditor extends StatelessWidget with FlowyOverlayDelegate {
|
|||||||
//
|
//
|
||||||
FlowyOverlay.of(context).insertWithAnchor(
|
FlowyOverlay.of(context).insertWithAnchor(
|
||||||
widget: OverlayContainer(
|
widget: OverlayContainer(
|
||||||
constraints: BoxConstraints.loose(const Size(_editorPannelWidth, 300)),
|
constraints: BoxConstraints.loose(const Size(_editorPanelWidth, 300)),
|
||||||
child: SizedBox(width: _editorPannelWidth, child: editor),
|
child: SizedBox(width: _editorPanelWidth, child: editor),
|
||||||
),
|
),
|
||||||
identifier: SelectOptionCellEditor.identifier(),
|
identifier: SelectOptionCellEditor.identifier(),
|
||||||
anchorContext: context,
|
anchorContext: context,
|
||||||
@ -161,7 +161,7 @@ class _TextField extends StatelessWidget {
|
|||||||
child: SelectOptionTextField(
|
child: SelectOptionTextField(
|
||||||
options: state.options,
|
options: state.options,
|
||||||
selectedOptionMap: optionMap,
|
selectedOptionMap: optionMap,
|
||||||
distanceToText: _editorPannelWidth * 0.7,
|
distanceToText: _editorPanelWidth * 0.7,
|
||||||
tagController: _tagController,
|
tagController: _tagController,
|
||||||
onClick: () => FlowyOverlay.of(context)
|
onClick: () => FlowyOverlay.of(context)
|
||||||
.remove(SelectOptionTypeOptionEditor.identifier),
|
.remove(SelectOptionTypeOptionEditor.identifier),
|
||||||
|
@ -32,10 +32,10 @@ class SelectOptionTextField extends StatelessWidget {
|
|||||||
required this.onNewTag,
|
required this.onNewTag,
|
||||||
required this.newText,
|
required this.newText,
|
||||||
this.onClick,
|
this.onClick,
|
||||||
TextEditingController? controller,
|
TextEditingController? textController,
|
||||||
FocusNode? focusNode,
|
FocusNode? focusNode,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : _controller = controller ?? TextEditingController(),
|
}) : _controller = textController ?? TextEditingController(),
|
||||||
_focusNode = focusNode ?? FocusNode(),
|
_focusNode = focusNode ?? FocusNode(),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ class SelectOptionTextField extends StatelessWidget {
|
|||||||
textfieldTagsController: tagController,
|
textfieldTagsController: tagController,
|
||||||
initialTags: selectedOptionMap.keys.toList(),
|
initialTags: selectedOptionMap.keys.toList(),
|
||||||
focusNode: _focusNode,
|
focusNode: _focusNode,
|
||||||
textSeparators: const [' ', ','],
|
textSeparators: const [','],
|
||||||
inputfieldBuilder: (BuildContext context, editController, focusNode,
|
inputfieldBuilder: (BuildContext context, editController, focusNode,
|
||||||
error, onChanged, onSubmitted) {
|
error, onChanged, onSubmitted) {
|
||||||
return ((context, sc, tags, onTagDelegate) {
|
return ((context, sc, tags, onTagDelegate) {
|
||||||
@ -70,6 +70,7 @@ class SelectOptionTextField extends StatelessWidget {
|
|||||||
|
|
||||||
if (text.isNotEmpty) {
|
if (text.isNotEmpty) {
|
||||||
onNewTag(text);
|
onNewTag(text);
|
||||||
|
focusNode.requestFocus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user