diff --git a/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java b/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java index 1a56a11201baf..222158fcd7d10 100644 --- a/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java +++ b/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java @@ -326,13 +326,6 @@ public boolean handleKeyEvent(KeyEvent event) { return true; } } - if (event.getAction() == KeyEvent.ACTION_UP - && (event.getKeyCode() == KeyEvent.KEYCODE_SHIFT_LEFT - || event.getKeyCode() == KeyEvent.KEYCODE_SHIFT_RIGHT)) { - int selEnd = Selection.getSelectionEnd(mEditable); - setSelection(selEnd, selEnd); - return true; - } return false; } diff --git a/shell/platform/android/test/io/flutter/plugin/editing/InputConnectionAdaptorTest.java b/shell/platform/android/test/io/flutter/plugin/editing/InputConnectionAdaptorTest.java index fbb44da41bcb7..93f92c182e0c2 100644 --- a/shell/platform/android/test/io/flutter/plugin/editing/InputConnectionAdaptorTest.java +++ b/shell/platform/android/test/io/flutter/plugin/editing/InputConnectionAdaptorTest.java @@ -551,7 +551,8 @@ public void testPerformPrivateCommand_dataIsFloatArray() throws JSONException { } @Test - public void testSendKeyEvent_shiftKeyUpCancelsSelection() { + public void testSendKeyEvent_shiftKeyUpDoesNotCancelSelection() { + // Regression test for https://github.com/flutter/flutter/issues/101569. int selStart = 5; int selEnd = 10; ListenableEditingState editable = sampleEditable(selStart, selEnd); @@ -560,8 +561,8 @@ public void testSendKeyEvent_shiftKeyUpCancelsSelection() { KeyEvent shiftKeyUp = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT); boolean didConsume = adaptor.handleKeyEvent(shiftKeyUp); - assertTrue(didConsume); - assertEquals(selEnd, Selection.getSelectionStart(editable)); + assertFalse(didConsume); + assertEquals(selStart, Selection.getSelectionStart(editable)); assertEquals(selEnd, Selection.getSelectionEnd(editable)); }