On Thu, 22 Dec 2022 10:33:15 GMT, Ajit Ghaisas <aghai...@openjdk.org> wrote:
>> When Text width was more than TextField width, the logic to update >> `textTranslateX` in `updateCaretOff` method was causing the issue of >> unexpected behavior for Right and Center alignment. >> >> Made changes to update `textTranslateX` in `updateCaretOff` method only when >> text width is less than text field width i.e `delta` is positive. >> For both right and center alignments, the `textTranslateX` value calculated >> in `updateTextPos` method will be updated without any condition so that >> expected behavior is achieved for all scenarios of text width relative to >> text field width. >> >> Added unit tests to validate LEFT, CENTER and RIGHT alignments. RIGHT and >> CENTER alignment tests are expected to fail without the fix provided in this >> PR. > > The proposed fix fixes the reported issue. > > **Regarding the question of changing current behavior of RIGHT alignment of > the TextField:** > If the string is larger than the TextField width - > - LEFT align should result in - Start of the text visible and end of the text > hidden. > - RIGHT align should result in - End of the text visible at the right edge of > the TextField and start of the text hidden. > > Right now, only the LEFT align behaves correctly. > RIGHT align behaves correctly only if the string is smaller than the > TextField width. The moment string length is larger than TextField width, it > starts behaving opposite (start of the text visible and end of the text > hidden.) > I don't know whether there is some rationale for this implementation or it is > a bug which went unnoticed till now. Noticed an issue similar to what @aghaisas reported earlier. - set TOP_RIGHT alignment (any _RIGHT in fact) - resize the field such that the text is wider than TextField can display - click on the first visible character and start typing Expected: the typed chars should appear in the view, the caret moves right, the remaining text scrolls right Observed: the typed characters appear to the left of the caret which does not move. It might behave differently when the caret is at the rightmost position next to the control edge, in which case the behavior is correct. Perhaps there ought to be some conditional logic implemented, but the way it behaves now when the caret is close to the left edge feels unnatural. ![Screenshot 2023-02-23 at 09 32 55](https://user-images.githubusercontent.com/107069028/220986606-1990cc60-1d33-4894-b93f-c9eac2202908.png) ------------- PR: https://git.openjdk.org/jfx/pull/980