Bug 218890
Summary: | REGRESSION (iOS 14): window.getSelection().getRangeAt(0) on iOS 14 WKWebView returns an incorrect startOffset | ||
---|---|---|---|
Product: | WebKit | Reporter: | xiehaiyan_xhy |
Component: | HTML Editing | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | darin, megan_gardner, rniwa, webkit-bug-importer, wenson_hsieh |
Priority: | P2 | Keywords: | InRadar |
Version: | Safari 14 | ||
Hardware: | iPhone / iPad | ||
OS: | Other | ||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=273469 |
xiehaiyan_xhy
In iOS 13 WKWebview and other browsers such as Chrome, when call window.getSelection().getRangeAt(0), it will return the tap character index.
But on iOS 14 WKWebview, window.getSelection().getRangeAt(0) doesn't return character index, but seems to return a word end index in en language.
My question is:
Can we fix this to keep the same as other browsers and iOS 13 WKWebView?
Details as below:
Code:
document.addEventListener('click', (event) => {
var range = window.getSelection().getRangeAt(0);
console.log("startOffset: "+ range.startOffset.toString());
});
Test case 1:
Action: There is a sentence in website as "Test click on website", click at the end of "e" in "Test".
Output:
In iOS 13 WKWebview and other browsers: startOffset: 2
In iOS 14 WKWebview: startOffset: 5
Also in iOS 14 WKWebview the word ending rule is not the same, when click on the first word in the node, return index will include whitespace, as we see in test case 1.
But some others return index which not include whitespace as Test case 2.
Test case 2:
There is a sentence in website as "Test click on website", tap at the end of "l" in "click"
Output:
In iOS 13 WKWebview and other browsers: startOffset: 7
In iOS 14 WKWebview: startOffset: 10
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/71403777>
Darin Adler
Oh no, this sounds like a bad regression. I assume I caused it with my work on the Selection API. Can we make a regression test to demonstrate? I’m really surprised we didn’t have a test.
xiehaiyan_xhy
Thanks a lot to look into this, Darin! Could you kindly share when the fix will be released to iOS? Thanks!
xiehaiyan_xhy
And it would be great to regress in other languages besides en, thanks!
Darin Adler
I’m not looking into it at this time. Just commented. I am inviting someone to help out by creating a regression test.
Darin Adler
Also would be good to know if anyone has examples of websites affected.