Skip to content

Commit

Permalink
[SuperEditor][web] Fix double tap closing the IME connection on Safar…
Browse files Browse the repository at this point in the history
…i/Firefox (Resolves #2513) (#2519)
  • Loading branch information
angelosilvestre authored and web-flow committed Jan 22, 2025
1 parent 7828068 commit c9bd887
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions super_editor/lib/src/default_editor/document_gestures_mouse.dart
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,10 @@ class _DocumentMouseInteractorState extends State<DocumentMouseInteractor> with
}

_selectionType = SelectionType.word;
_clearSelection();
bool didSelectContent = false;

if (docPosition != null) {
bool didSelectContent = _selectWordAt(
didSelectContent = _selectWordAt(
docPosition: docPosition,
docLayout: _docLayout,
);
Expand All @@ -389,6 +389,15 @@ class _DocumentMouseInteractorState extends State<DocumentMouseInteractor> with
}
}

// Only clear the existing selection if we were not able to place a new selection,
// because clearing the selection might close the IME connection, depending
// on the `SuperEditorImePolicies` used. If we cleared the selection and then
// placed a new selection, the IME connection would be closed and then immediately
// reopened, and this doesn't seem to work on Safari and Firefox.
if (!didSelectContent) {
_clearSelection();
}

_focusNode.requestFocus();
}

Expand Down

0 comments on commit c9bd887

Please sign in to comment.