Repository navigation
Arrow keys in RTL move the wrong way #78660
Copy link
Copy link
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)Supporting other languages or locales. (aka i18n)a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsfound in release: 2.1Found to occur in 2.1Found to occur in 2.1has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
The left/right arrow keys should move the caret left/right respectively, regardless of the text direction. In Flutter they move in the wrong direction in RTL text.
The methods that handle this in RenderEditable should be updated to perform the correct behavior without being renamed. So for example, the method _moveGivenSelectionLeft actually moves the selection upstream right now, not necessarily left. It should be modified to move the selection left like it says. This is out of date, see below.
Steps to Reproduce
- Run the app below, which is just a TextField with some Arabic text in it, on a device with arrow keys.
- Try to navigate with the left and right arrow keys.
Expected results: The cursor moves left with the left key and right with the right key. Tested on TextEdit on a Mac after changing my keyboard to Arabic.
Actual results: The cursor movement direction is reversed.
Code
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final TextEditingController controller = TextEditingController(text: 'شسيب');
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: TextField(
controller: controller,
),
),
),
);
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)Supporting other languages or locales. (aka i18n)a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsfound in release: 2.1Found to occur in 2.1Found to occur in 2.1has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Activity
TahaTesser commentedon Mar 30, 2021
I can reproduce on an Android device
flutter doctor -v
[✓] Flutter (Channel master, 2.1.0-13.0.pre.323, on Microsoft Windows [Version 10.0.19042.870], locale en-US) • Flutter version 2.1.0-13.0.pre.323 at C:\Users\Taha\Code\flutter_master • Framework revision 2cdd51900c (5 hours ago), 2021-03-30 10:16:05 +0200 • Engine revision dbcbf69a57 • Dart version 2.13.0 (build 2.13.0-175.0.dev) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\Taha\Code\SDK • Platform android-30, build-tools 30.0.3 • ANDROID_HOME = C:\Users\Taha\Code\SDK • Java binary at: C:\Users\Taha\Code\android-studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted. [✓] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.2) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community • Visual Studio Community 2019 version 16.9.31112.23 • Windows 10 SDK version 10.0.19041.0 [✓] Android Studio (version 4.1.0) • Android Studio at C:\Users\Taha\Code\android-studio • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) [✓] VS Code (version 1.54.3) • VS Code at C:\Users\Taha\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.20.0 [✓] Connected device (4 available) • Redmi K20 Pro (mobile) • def0ad20 • android-arm64 • Android 10 (API 29) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19042.870] • Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.90 • Edge (web) • edge • web-javascript • Microsoft Edge 89.0.774.63 • No issues found!PollexLee commentedon Mar 31, 2021
Reproduced on my Android and iOS devices

flutter doctor -v
noga-dev commentedon May 14, 2021
Works now!
Link with video evidence:
https://twitter.com/noga_dev/status/1393190403504017409?s=20
Flutter doctor -v
Edit: spoke too soon. Combining LTR with RTL results in some undesired side effects...
Viper-Bit commentedon May 26, 2022
cedvdb commentedon Jul 27, 2022
REPRO
Result
The caret behavior is that it does not follow the arrows and seemingly heratic.
naory159 commentedon Nov 26, 2022
peretsoli commentedon Jan 29, 2023
mamaly12 commentedon Jun 21, 2023
Hi there,
I also have the same problem. Any update regarding this issue would be appreciated.
justinmc commentedon Jun 21, 2023
@LongCatIsLooong maybe there is a simple fix for this with your Intent/Action system in EditableText? I think the Intents that handle cursor movement use a forward boolean to decide the direction, but maybe this should specifically indicate left/right in some situations?
14 remaining items
fix flutter#78660
תיקון: כיוון בחירת טקסט עם Shift+חץ ב-RTL (עברית)
Cache the paint offset adjusted line metrics in TextPainter (flutter#…