JDK-8296266 : TextArea: Navigation breaks with RTL text
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: jfx20
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2022-11-02
  • Updated: 2024-11-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
It looks like left-arrow navigation breaks if the text contains RTL characters.

 * To reproduce:
 * place the cursor on a line following "Arabic: العربية"
 * and try going back with arrow-left key.

Alternatively, simply inserting the following string into a TextArea results in left arrow / right arrow keys inoperable, even when the right font is selected:
"Arabic: \u0627\u0644\u0639\u0631\u0628\u064a\u0629";

(use MonkeyTester TextArea page, set Al Bayan Bold font on Mac, for example)

Fails on Mac Ventura 13.1 and Windows 11

edit 2023/10/11:
1. The navigation also fails with jsk 1.8.0_131 (windows 10) but slightly differently.  the cursor does move across LTR text, then fails somewhere in the middle of RTL (Hebrew) text.  Try this text string: Hebrew עִבְֿרִית, Ivrit
"Hebrew \u05e2\u05b4\u05d1\u05b0\u05bf\u05e8\u05b4\u05d9\u05ea, Ivrit"

2. Looks like there exist a wide variety of behaviors with respect to bidi text, summarized in this gist:
https://gist.github.com/andy-goryachev-oracle/4802f9380fb03ec2be7ac36bd98a2059
The question is - how FX should work, considering that it seems to be navigating differently than swing in jfx8, and it might work differently (though we never know because it never did) with jfx17+?

Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/1220 Date: 2023-08-22 20:46:21 +0000
25-08-2023

i would have reclassified this bug as P3, since there is no work-around and user experience is severely hampered.
22-08-2023

Added a screenshot illustrating the irregularities using the caretShape() / rangeShape() methods with the TextFlow containing text that causes the issue. Code to generate colors shapes (modeled after TextAreaSkin.nextCharacterVisually()): ``` public static Group createFor(TextFlow textNode) { ShowCharacterRuns r = new ShowCharacterRuns(); int len = getTextLength(textNode); for (int i = 0; i < len; i++) { PathElement[] caret = textNode.caretShape(i, true); if (caret.length == 4) { caret = new PathElement[] { caret[0], caret[1] }; } Bounds caretBounds = new Path(caret).getLayoutBounds(); double x = caretBounds.getMaxX(); double y = (caretBounds.getMinY() + caretBounds.getMaxY()) / 2; HitInfo hit = textNode.hitTest(new Point2D(x, y)); Path cs = new Path(textNode.rangeShape(hit.getCharIndex(), hit.getCharIndex() + 1)); Color c = color(i); cs.setFill(c); cs.setStroke(c); r.getChildren().add(cs); } return r; } private static Color color(int i) { switch(i % 3) { case 0: return Color.rgb(255, 0, 0, 0.5); case 1: return Color.rgb(0, 255, 0, 0.5); default: return Color.rgb(0, 0, 255, 0.5); } } ```
14-02-2023

Maybe related to: https://bugs.openjdk.org/browse/JDK-8248914 There is some weird listener chain in TextField and TextArea.
03-11-2022