Bug 220522

Summary: getSelection().focusNode in iOS is not pointing to the correct node
Product: WebKit Reporter: Kyle <kkeating>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal    
Priority: P2    
Version: WebKit Nightly Build   
Hardware: iPhone / iPad   
OS: iOS 14   

Description Kyle 2021-01-11 12:05:54 PST
document.getSelection().focusNode behavior difference on iOS than it is on Android, MacOS and Windows 10.

Minimal example:
https://kyle-keating.s3-us-west-1.amazonaws.com/getSelection_issue.html

This is a simple html page with two paragraphs. As you make a selection to highlight text (using a mouse or touch device), the value of the focusNode is reported in the input field.


Using a webkit browser on the desktop (such as Safari), 

1. Highlight text in the first paragraph and drag the selection to the second. Notice the value of the input field changes from the text in the first paraph to the second.
2. Repeat this same test but start from the second paraph and drag and select up to the first. Notice the value of the input field changes from the text in the second paraph to the first.

I assume this is the correct behavior.

Now, using an iOS device perform the same two tests. The second test fails as the value of focusNode does not change when making a selection from a node lower in the DOM to one higher. I believe this is a bug.
Comment 1 Alexey Proskuryakov 2021-01-11 16:50:40 PST

*** This bug has been marked as a duplicate of bug 220523 ***