diff --git a/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart b/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart index 2b771be04..0008c233b 100644 --- a/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart +++ b/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart @@ -19,6 +19,14 @@ class RichTextMobileTabletController extends GetxController { Future get isEditorFocused async => await htmlEditorApi?.hasFocus() ?? false; + Future focus() async { + try { + await htmlEditorApi?.webViewController.evaluateJavascript(source: "document.getElementById('editor').focus();"); + } catch (e) { + logWarning('RichTextMobileTabletController::focus:Exception: $e'); + } + } + void insertImage(InlineImage inlineImage) async { final isFocused = await isEditorFocused; log('RichTextMobileTabletController::insertImage: isEditorFocused = $isFocused'); diff --git a/lib/features/composer/presentation/extensions/ai_scribe/handle_ai_scribe_in_composer_extension.dart b/lib/features/composer/presentation/extensions/ai_scribe/handle_ai_scribe_in_composer_extension.dart index 7b3e5c094..27ea9a451 100644 --- a/lib/features/composer/presentation/extensions/ai_scribe/handle_ai_scribe_in_composer_extension.dart +++ b/lib/features/composer/presentation/extensions/ai_scribe/handle_ai_scribe_in_composer_extension.dart @@ -148,6 +148,14 @@ extension HandleAiScribeInComposerExtension on ComposerController { } } + Future ensureMobileEditorFocused() async { + try { + await richTextMobileTabletController?.focus(); + } catch (e) { + logError('$runtimeType::ensureMobileEditorFocused:Exception = $e'); + } + } + void clearTextInEditor() { try { if (PlatformInfo.isWeb) { @@ -207,6 +215,10 @@ extension HandleAiScribeInComposerExtension on ComposerController { AiScribeSuggestionActions action, String suggestionText, ) async { + if (PlatformInfo.isMobile) { + await ensureMobileEditorFocused(); + } + switch (action) { case AiScribeSuggestionActions.replace: await onReplaceTextCallback(suggestionText);