Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SuperEditor][web] Fix double tap closing the IME connection on Safari/Firefox (Resolves #2513) #2519

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[SuperEditor][web] Fix double tap closing the IME connection on Safar…
…i/Firefox (Resolves #2513)
  • Loading branch information
angelosilvestre committed Jan 18, 2025
commit 99601c7b1dc3f62d0525d7a820e4140da6a6d24b
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
Loading