Skip to content

RTL textField Cursor movement has a problem with the last position and Emojies and text selection #120049

@AmirhosseinShk

Description

@AmirhosseinShk

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. type some things in text field like Screenshots that are attached
  3. try to move the cursor on different words and goes to the last words and move the cursor to the last position

Expected results: we want the cursor to move to the last position without any problems

Actual results: As indicated in the screenshots the cursor stuck before the last position and can't move it to last position of words

for an additional report, this problem occurs when using a Persian or Arabic keyboard for typing and we use a special font for our text this makes other bugs that this issue repeats for each line of text for the normal situation this just occurs on the last line of the paragraph. also if using Emojies this problem repeats again or for text selection, we can select the last character of words.

another issue that should be mentioned here is the cursor movement problem for Persian keyboards when characters stick together this makes a bug that the issue stuck in the wrong position and when u typing something these words display in another position that does not match with your selected position

Sample Code put on main.dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
            Padding(
              padding: const EdgeInsets.all(28.0),
              child: TextField(textDirection: TextDirection.rtl,maxLines: null,),
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
Logs

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.7.1, on Microsoft Windows [Version 10.0.19044.2486], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Professional 2019 16.11.22)  
[√] Android Studio (version 2021.1)
[√] IntelliJ IDEA Community Edition (version 2021.3)
[√] VS Code (version 1.73.1)
[√] Connected device (4 available)
[!] HTTP Host Availability
    X HTTP host "https://cocoapods.org/" is not reachable. Reason: An error occurred while checking the HTTP host: The connection terminated during
      handshake

! Doctor found issues in 1 category.

image
The image about the cursor stuck behind the last Emojies

image
this image is about moving the cursor to the middle of the words and the cursor stuck in this position but if u typing, type in another position

image
this image is about the problem with the last char of a word that doesn't let you move the cursor behind it or select it

https://user-images.githubusercontent.com/28021064/216845203-1eccc103-6252-4e1c-9434-885992e0ccbc.mp4
the video that shows the problem with the cursor on Persian words

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsf: selectionSelectableRegion, SelectionArea, SelectionContainer, Selectable, and related APIsfound in release: 3.7Found to occur in 3.7found in release: 3.8Found to occur in 3.8frameworkflutter/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