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

fix: cancel block selection when tapping the editor on mobile #956

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ class _MobileSelectionServiceWidgetState
editorState.updateSelectionWithReason(
selection,
reason: SelectionUpdateReason.uiEvent,
customSelectionType: SelectionType.inline,
extraInfo: {
selectionDragModeKey: dragMode,
selectionExtraInfoDoNotAttachTextService:
Expand Down Expand Up @@ -525,6 +526,7 @@ class _MobileSelectionServiceWidgetState
editorState.updateSelectionWithReason(
selection,
reason: SelectionUpdateReason.uiEvent,
customSelectionType: SelectionType.inline,
extraInfo: null,
);
}
Expand Down Expand Up @@ -598,6 +600,7 @@ class _MobileSelectionServiceWidgetState
editorState.updateSelectionWithReason(
editorState.selection,
reason: SelectionUpdateReason.uiEvent,
customSelectionType: SelectionType.inline,
extraInfo: {
selectionExtraInfoDoNotAttachTextService: false,
},
Expand All @@ -618,6 +621,7 @@ class _MobileSelectionServiceWidgetState
editorState.updateSelectionWithReason(
Selection.collapsed(position),
reason: SelectionUpdateReason.uiEvent,
customSelectionType: SelectionType.inline,
extraInfo: null,
);
}
Expand Down
14 changes: 11 additions & 3 deletions lib/src/editor_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,15 @@
selectionNotifier.value = value;
}

SelectionType? selectionType;
SelectionType? _selectionType;
set selectionType(SelectionType? value) {
if (value == _selectionType) {
return;
}
_selectionType = value;
}

SelectionType? get selectionType => _selectionType;

SelectionUpdateReason _selectionUpdateReason = SelectionUpdateReason.uiEvent;
SelectionUpdateReason get selectionUpdateReason => _selectionUpdateReason;
Expand Down Expand Up @@ -243,12 +251,12 @@
final completer = Completer<void>();

if (reason == SelectionUpdateReason.uiEvent) {
selectionType = customSelectionType ?? SelectionType.inline;
_selectionType = customSelectionType ?? SelectionType.inline;
WidgetsBinding.instance.addPostFrameCallback(
(timeStamp) => completer.complete(),
);
} else if (customSelectionType != null) {
selectionType = customSelectionType;
_selectionType = customSelectionType;

Check warning on line 259 in lib/src/editor_state.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor_state.dart#L259

Added line #L259 was not covered by tests
}

// broadcast to other users here
Expand Down
Loading