[Android] Do not collapse text selection on shift key up (flutter/engine#42075)
Fixes https://github.com/flutter/flutter/issues/101569 This block of code was originally introduced in https://github.com/flutter/engine/pull/15560 , but removing it does not have any affect on the software text editing controls in GBoard. Before this change * shift + arrow right/left selection would collapse after releasing the shift key. * shift + mouse click to expand selection would collapse after releasing the shift key. After this change * shift key up no longer collapses the selection.
This commit is contained in:
@@ -326,13 +326,6 @@ public class InputConnectionAdaptor extends BaseInputConnection
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -551,7 +551,8 @@ public class InputConnectionAdaptorTest {
|
||||
}
|
||||
|
||||
@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 class InputConnectionAdaptorTest {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user