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

Prevented indentation when the TAB key is pressed on a hardware keyboard during IME input #2375

Closed
wants to merge 1 commit into from
Closed
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 @@ -26,6 +26,7 @@ class EditorKeyboardShortcuts extends StatelessWidget {
required this.controller,
required this.readOnly,
required this.enableAlwaysIndentOnTab,
required this.isImeComposingActive,
required this.characterEvents,
required this.spaceEvents,
this.onKeyPressed,
Expand All @@ -36,6 +37,7 @@ class EditorKeyboardShortcuts extends StatelessWidget {

final bool readOnly;
final bool enableAlwaysIndentOnTab;
final bool isImeComposingActive;
final QuillController controller;
@experimental
final KeyEventResult? Function(KeyEvent event, Node? node)? onKeyPressed;
Expand Down Expand Up @@ -78,6 +80,10 @@ class EditorKeyboardShortcuts extends StatelessWidget {
}

KeyEventResult _onKeyEvent(node, KeyEvent event) {
// Don't handle key if IME is active.
if (isImeComposingActive) {
return KeyEventResult.ignored;
}
final onKey = onKeyPressed;
if (onKey != null) {
// Find the current node the user is on.
Expand Down
1 change: 1 addition & 0 deletions lib/src/editor/raw_editor/raw_editor_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ class QuillRawEditorState extends EditorState
controller: controller,
readOnly: widget.config.readOnly,
enableAlwaysIndentOnTab: widget.config.enableAlwaysIndentOnTab,
isImeComposingActive: isImeComposingActive,
customShortcuts: widget.config.customShortcuts,
customActions: widget.config.customActions,
child: child,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ mixin RawEditorStateTextInputClientMixin on EditorState
}
}

bool get isImeComposingActive {
final isComposingValid =
_lastKnownRemoteTextEditingValue?.composing.isValid ?? false;
final isSelectionValid =
_lastKnownRemoteTextEditingValue?.selection.isValid ?? false;

return isComposingValid && isSelectionValid;
}

TextEditingValue? get _lastKnownRemoteTextEditingValue =>
__lastKnownRemoteTextEditingValue;

Expand Down
Loading