Skip to content

Commit c62263e

Browse files
angelosilvestrematthew-carroll
authored andcommitted
[SuperEditor][web] Fix double tap closing the IME connection on Safari/Firefox (Resolves #2513) (#2519)
1 parent 7828068 commit c62263e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

super_editor/lib/src/default_editor/document_gestures_mouse.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,10 @@ class _DocumentMouseInteractorState extends State<DocumentMouseInteractor> with
364364
}
365365

366366
_selectionType = SelectionType.word;
367-
_clearSelection();
367+
bool didSelectContent = false;
368368

369369
if (docPosition != null) {
370-
bool didSelectContent = _selectWordAt(
370+
didSelectContent = _selectWordAt(
371371
docPosition: docPosition,
372372
docLayout: _docLayout,
373373
);
@@ -389,6 +389,15 @@ class _DocumentMouseInteractorState extends State<DocumentMouseInteractor> with
389389
}
390390
}
391391

392+
// Only clear the existing selection if we were not able to place a new selection,
393+
// because clearing the selection might close the IME connection, depending
394+
// on the `SuperEditorImePolicies` used. If we cleared the selection and then
395+
// placed a new selection, the IME connection would be closed and then immediately
396+
// reopened, and this doesn't seem to work on Safari and Firefox.
397+
if (!didSelectContent) {
398+
_clearSelection();
399+
}
400+
392401
_focusNode.requestFocus();
393402
}
394403

0 commit comments

Comments
 (0)