Skip to content

Commit

Permalink
TF-3399 Fix can not click on body of composer in Samsung A3
Browse files Browse the repository at this point in the history
  • Loading branch information
dab246 committed Jan 7, 2025
1 parent 57a22b9 commit e52fe48
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 114 deletions.
18 changes: 8 additions & 10 deletions lib/features/composer/presentation/composer_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class ComposerController extends BaseController
SignatureStatus _identityContentOnOpenPolicy = SignatureStatus.editedAvailable;
int? _savedEmailDraftHash;
bool _restoringSignatureButton = false;
GlobalKey? responsiveContainerKey;

@visibleForTesting
bool get restoringSignatureButton => _restoringSignatureButton;
Expand Down Expand Up @@ -230,6 +231,7 @@ class ComposerController extends BaseController
super.onInit();
if (PlatformInfo.isWeb) {
richTextWebController = getBinding<RichTextWebController>();
responsiveContainerKey = GlobalKey();
} else {
richTextMobileTabletController = getBinding<RichTextMobileTabletController>();
}
Expand Down Expand Up @@ -269,6 +271,7 @@ class ComposerController extends BaseController
_beforeReconnectManager.removeListener(onBeforeReconnect);
if (PlatformInfo.isWeb) {
richTextWebController = null;
responsiveContainerKey = null;
} else {
richTextMobileTabletController = null;
}
Expand Down Expand Up @@ -392,12 +395,6 @@ class ComposerController extends BaseController
}
});
});

if (richTextWebController != null) {
ever(richTextWebController!.formattingOptionsState, (_) {
richTextWebController!.editorController.setFocus();
});
}
}

void _triggerBrowserEventListener() {
Expand Down Expand Up @@ -525,6 +522,7 @@ class ComposerController extends BaseController

KeyEventResult _subjectEmailInputOnKeyListener(FocusNode node, KeyEvent event) {
if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.tab) {
subjectEmailInputFocusNode?.unfocus();
richTextWebController?.editorController.setFocus();
return KeyEventResult.handled;
}
Expand Down Expand Up @@ -1490,6 +1488,9 @@ class ComposerController extends BaseController
}

void displayScreenTypeComposerAction(ScreenDisplayMode displayMode) async {
if (screenDisplayMode.value == ScreenDisplayMode.minimize) {
_isEmailBodyLoaded = false;
}
if (richTextWebController != null && screenDisplayMode.value != ScreenDisplayMode.minimize) {
final textCurrent = await richTextWebController!.editorController.getText();
richTextWebController!.editorController.setText(textCurrent);
Expand Down Expand Up @@ -1959,7 +1960,6 @@ class ComposerController extends BaseController
return false;
}


void handleInitHtmlEditorWeb(String initContent) async {
if (_isEmailBodyLoaded) return;
log('ComposerController::handleInitHtmlEditorWeb:');
Expand All @@ -1984,9 +1984,7 @@ class ComposerController extends BaseController
richTextWebController?.closeAllMenuPopup();
}

void handleOnMouseDownHtmlEditorWeb(BuildContext context) {
Navigator.maybePop(context);
FocusScope.of(context).unfocus();
void handleOnMouseDownHtmlEditorWeb() {
_collapseAllRecipient();
_autoCreateEmailTag();
}
Expand Down
6 changes: 3 additions & 3 deletions lib/features/composer/presentation/composer_view_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class ComposerView extends GetWidget<ComposerController> {
child: Padding(
padding: ComposerStyle.mobileEditorPadding,
child: Obx(() => WebEditorView(
key: controller.responsiveContainerKey,
editorController: controller.richTextWebController!.editorController,
arguments: controller.composerArguments.value,
contentViewState: controller.emailContentsViewState.value,
Expand All @@ -196,7 +197,6 @@ class ComposerView extends GetWidget<ComposerController> {
onMouseDown: controller.handleOnMouseDownHtmlEditorWeb,
onEditorSettings: controller.richTextWebController!.onEditorSettingsChange,
onEditorTextSizeChanged: controller.richTextWebController!.onEditorTextSizeChanged,
width: constraints.maxWidth,
height: constraints.maxHeight,
onDragEnter: controller.handleOnDragEnterHtmlEditorWeb,
onPasteImageSuccessAction: (listFileUpload) => controller.handleOnPasteImageSuccessAction(
Expand Down Expand Up @@ -448,6 +448,7 @@ class ComposerView extends GetWidget<ComposerController> {
padding: ComposerStyle.desktopEditorPadding,
child: Obx(() {
return WebEditorView(
key: controller.responsiveContainerKey,
editorController: controller.richTextWebController!.editorController,
arguments: controller.composerArguments.value,
contentViewState: controller.emailContentsViewState.value,
Expand All @@ -458,7 +459,6 @@ class ComposerView extends GetWidget<ComposerController> {
onMouseDown: controller.handleOnMouseDownHtmlEditorWeb,
onEditorSettings: controller.richTextWebController?.onEditorSettingsChange,
onEditorTextSizeChanged: controller.richTextWebController?.onEditorTextSizeChanged,
width: constraints.maxWidth,
height: constraints.maxHeight,
onDragEnter: controller.handleOnDragEnterHtmlEditorWeb,
onPasteImageSuccessAction: (listFileUpload) => controller.handleOnPasteImageSuccessAction(
Expand Down Expand Up @@ -728,6 +728,7 @@ class ComposerView extends GetWidget<ComposerController> {
child: Padding(
padding: ComposerStyle.tabletEditorPadding,
child: Obx(() => WebEditorView(
key: controller.responsiveContainerKey,
editorController: controller.richTextWebController!.editorController,
arguments: controller.composerArguments.value,
contentViewState: controller.emailContentsViewState.value,
Expand All @@ -738,7 +739,6 @@ class ComposerView extends GetWidget<ComposerController> {
onMouseDown: controller.handleOnMouseDownHtmlEditorWeb,
onEditorSettings: controller.richTextWebController!.onEditorSettingsChange,
onEditorTextSizeChanged: controller.richTextWebController!.onEditorTextSizeChanged,
width: constraints.maxWidth,
height: constraints.maxHeight,
onDragEnter: controller.handleOnDragEnterHtmlEditorWeb,
onPasteImageSuccessAction: (listFileUpload) => controller.handleOnPasteImageSuccessAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ class RichTextWebController extends BaseRichTextController {
: FormattingOptionsState.enabled;

formattingOptionsState.value = newState;

if (isFormattingOptionsEnabled) {
FocusManager.instance.primaryFocus?.unfocus();
editorController.setFocus();
}
}

bool get isFormattingOptionsEnabled => formattingOptionsState.value == FormattingOptionsState.enabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
final OnMouseDownEditorAction? onMouseDown;
final OnEditorSettingsChange? onEditorSettings;
final OnEditorTextSizeChanged? onEditorTextSizeChanged;
final double? width;
final double? height;
final OnDragEnterListener? onDragEnter;
final OnPasteImageSuccessAction? onPasteImageSuccessAction;
Expand All @@ -49,7 +48,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
this.onMouseDown,
this.onEditorSettings,
this.onEditorTextSizeChanged,
this.width,
this.height,
this.onDragEnter,
this.onPasteImageSuccessAction,
Expand Down Expand Up @@ -78,7 +76,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
onMouseDown: onMouseDown,
onEditorSettings: onEditorSettings,
onEditorTextSizeChanged: onEditorTextSizeChanged,
width: width,
height: height,
onDragEnter: onDragEnter,
onPasteImageSuccessAction: onPasteImageSuccessAction,
Expand Down Expand Up @@ -106,7 +103,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
onMouseDown: onMouseDown,
onEditorSettings: onEditorSettings,
onEditorTextSizeChanged: onEditorTextSizeChanged,
width: width,
height: height,
onDragEnter: onDragEnter,
onPasteImageSuccessAction: onPasteImageSuccessAction,
Expand Down Expand Up @@ -134,7 +130,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
onMouseDown: onMouseDown,
onEditorSettings: onEditorSettings,
onEditorTextSizeChanged: onEditorTextSizeChanged,
width: width,
height: height,
onDragEnter: onDragEnter,
onPasteImageSuccessAction: onPasteImageSuccessAction,
Expand Down Expand Up @@ -170,7 +165,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
onMouseDown: onMouseDown,
onEditorSettings: onEditorSettings,
onEditorTextSizeChanged: onEditorTextSizeChanged,
width: width,
height: height,
onDragEnter: onDragEnter,
onPasteImageSuccessAction: onPasteImageSuccessAction,
Expand Down Expand Up @@ -202,7 +196,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
onMouseDown: onMouseDown,
onEditorSettings: onEditorSettings,
onEditorTextSizeChanged: onEditorTextSizeChanged,
width: width,
height: height,
onDragEnter: onDragEnter,
onPasteImageSuccessAction: onPasteImageSuccessAction,
Expand All @@ -224,7 +217,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
onMouseDown: onMouseDown,
onEditorSettings: onEditorSettings,
onEditorTextSizeChanged: onEditorTextSizeChanged,
width: width,
height: height,
onDragEnter: onDragEnter,
onPasteImageSuccessAction: onPasteImageSuccessAction,
Expand Down
Loading

0 comments on commit e52fe48

Please sign in to comment.