Skip to content

Arrow keys in RTL move the wrong way #78660

@justinmc

Description

@justinmc

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

  1. Run the app below, which is just a TextField with some Arabic text in it, on a device with arrow keys.
  2. 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,
          ),
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)a: text inputEntering text in a text field or keyboard related problemsf: material designflutter/packages/flutter/material repository.found in release: 2.1Found to occur in 2.1frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions