window.getSelection().getRangeAt(0) is giving indexSizeError after selecting text from wkwebview in iOS 17. We are using evaluateJavascript functions for interactions. This was working fine in earlier versions. This problem is seen since the recent iOS 17 upgrade.
Javascript indexSizeError for window.getSelection().getRangeAt(0) in WKWebview in iOS 17
Probably best to file a bug on <https://bugs.webkit.org/> with a test HTML file (or URL) that reproduces the issue.
window.getSelection() actually works fine. The problem here is because when the focus is lost, then the selection is cleared as well.