Fix keyboard pops up when resizing the image

pull/890/head
X Code 3 years ago
parent 401f317690
commit 680a5db531
  1. 4
      lib/src/widgets/controller.dart
  2. 6
      lib/src/widgets/embeds/default_embed_builder.dart
  3. 12
      lib/src/widgets/raw_editor.dart

@ -62,6 +62,10 @@ class QuillController extends ChangeNotifier {
bool ignoreFocusOnTextChange = false;
/// Skip requestKeyboard being called in
/// RawEditorState#_didChangeTextEditingValue
bool skipRequestKeyboard = false;
/// True when this [QuillController] instance has been disposed.
///
/// A safety mechanism to ensure that listeners don't crash when adding,

@ -84,8 +84,10 @@ Widget defaultEmbedBuilder(
controller, controller.selection.start);
final attr = replaceStyleString(
getImageStyleString(controller), w, h);
controller.formatText(
res.item1, 1, StyleAttribute(attr));
controller
..skipRequestKeyboard = true
..formatText(
res.item1, 1, StyleAttribute(attr));
},
imageWidth: _widthHeight?.item1,
imageHeight: _widthHeight?.item2,

@ -708,7 +708,11 @@ class RawEditorState extends EditorState
if (kIsWeb) {
_onChangeTextEditingValue(ignoreFocus);
if (!ignoreFocus) {
requestKeyboard();
if (controller.skipRequestKeyboard) {
controller.skipRequestKeyboard = false;
} else {
requestKeyboard();
}
}
return;
}
@ -716,7 +720,11 @@ class RawEditorState extends EditorState
if (ignoreFocus || _keyboardVisible) {
_onChangeTextEditingValue(ignoreFocus);
} else {
requestKeyboard();
if (controller.skipRequestKeyboard) {
controller.skipRequestKeyboard = false;
} else {
requestKeyboard();
}
if (mounted) {
setState(() {
// Use widget.controller.value in build()

Loading…
Cancel
Save