Skip to content

[Bug]: Incorrect selection and cursor behavior for RTL text in IText #10714

@Nasser-sw

Description

@Nasser-sw

CheckList

  • I agree to follow this project's Code of Conduct
  • I have read and followed the Contributing Guide
  • I have read and followed the Issue Tracker Guide
  • I have searched and referenced existing issues and discussions
  • I am filing a BUG report.
  • I have managed to reproduce the bug after upgrading to the latest version
  • I have created an accurate and minimal reproduction

Version

6.6.4

In What environments are you experiencing the problem?

No response

Node Version (if applicable)

None

Link To Reproduction

https://codesandbox.io/p/devbox/fabric-nextjs-sandbox-forked-987kpy?workspaceId=ws_KPJkdGmaFKAMNymeZsxKvE

Steps To Reproduce

1- Initialize a Fabric.js canvas.

2- Create an IText object with an Arabic string, for example: 'هذه تجربة'.

3- Do not specify the direction property, allowing it to default to 'ltr'.

4- Add the text object to the canvas.

5- Using the mouse, attempt to click on the first word as it appears visually (the word هذه on the far right).

6- Attempt to click and drag to select the text from right to left.

7- Try to change a word it will change the opposite.

Expected Behavior

Intuitive Selection: The selection highlight should follow the mouse's path accurately, expanding from right to left as the user drags.

WYSIWYG Editing: Typing and deleting characters should happen at the cursor's visual position, providing a predictable "What You See Is What You Get" experience.

Actual Behavior

Reversed Selection: Dragging the mouse from right to left creates a selection highlight that expands in the opposite direction (from left to right).

Incorrect Editing: Typing or deleting characters affects the opposite end of the text from where the cursor appears visually. The editing logic follows the LTR model, which is disconnected from the visual RTL rendering.

Error Message & Stack Trace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions