Open Bug 1490304 Opened 7 years ago Updated 3 years ago

Cursor jumps to wrong horizontal position when pressing up/down after setting selection through Selection API

Categories

(Core :: DOM: Editor, defect, P3)

63 Branch
Unspecified
All
defect

Tracking

()

Tracking Status
firefox62 --- affected
firefox63 --- affected
firefox64 --- unaffected

People

(Reporter: stef.busking, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36 Steps to reproduce: Reproducible example at https://codepen.io/Bwrrp/pen/PdRZzx The example contains two paragraphs in a content-editable div. Place the cursor in the first paragraph and press the right arrow a number of times to move a good distance horizontally. Then press the down arrow to move the cursor down. Now do the same to go left, then up. Actual results: After moving down as expected, the second and any further attempts to move vertically using up/down seem to ignore any horizontal movement performed by going left or right since the last vertical movement. Note that the left and right arrow keys move the cursor using JavaScript and the Selection API. Moving up and down uses the native behavior. It seems that the horizontal position used for moving to the next / previous line is not updated correctly when JS is used to move the cursor, and any vertical movement afterwards is based on an older position. Pressing up/down or clicking anywhere to place the cursor does update this horizontal position, so the next vertical movement behaves as expected. Expected results: Expected vertical cursor movement to always move to a position above / below the previous cursor position, even if that previous position was set using the Selection API.
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0 (20180913100107) I have tested this report on Windows 10 and Ubuntu 18.04 using the latest Nightly, Beta and Fx release builds. I was able to reproduce the mentioned behavior using the provided codepen page. After moving down as expected, the second and any further attempts to move vertically using up/down seem to ignore any horizontal movement performed by going left or right since the last vertical movement. Please change if this is not the correct component!
Status: UNCONFIRMED → NEW
Component: Untriaged → Event Handling
Ever confirmed: true
OS: Unspecified → All
Product: Firefox → Core
Component: Event Handling → Editor
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.