New issue
Advanced search Search tips

Issue 737005 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

onfocus event is firing again when selection is changed first time

Reported by lge-systemwebview@lge.com, Jun 27 2017

Issue description

THIS TEMPLATE IS FOR FILING BUGS ON THE ANDROID SYSTEM WEBVIEW. GENERAL WEB
BUGS SHOULD BE FILED USING A DIFFERENT TEMPLATE!

Device name: LG G6, Samsung S6
Android version: 7.0
WebView version (from system settings -> Apps -> Android System WebView):58.0.3029.83
Application: Sample App
Application version:

URLs (if applicable):



Steps to reproduce:
(1) Install the APK
(2) Cursor is in Subject->Click IME Next button
(3) Observe focus event is fired twice

Expected result:
focus event behavior should be uniform

Actual result:
focus event is fired again.


Whenever user clicks IME next to focus Webview editor, focus is coming to editor but cursor is not placed by WebView by default. 
To overcome that, we are placing the cursor manually by creating the collapsed range and adding to selection (See setCaretPositionForInsert function in the attached source code) during focus event.

But when addRange is called, focus event is fired one more time. This second time focus event is effecting the internal logic.



 
Attached APK and sample app source code.
WebViewSampleApp.apk
464 KB Download
WebViewSampleApp.zip
80.0 KB Download
Labels: Needs-Feedback
Is this a regression from behaviour a previous webview version?

Comment 3 Deleted

Comment 4 Deleted

Project Member

Comment 5 by sheriffbot@chromium.org, Jun 29 2017

Cc: tobiasjs@chromium.org
Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "tobiasjs@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 6 by boliu@chromium.org, Jul 10 2017

Labels: Needs-Feedback
not sure why comment 3/4 are deleted, but it used to say "This behavior was observed in previous stable version also."

The apk you attached doesn't run. Presumably it's a multi-dex apk and you only included the main apk.

Also which focus event are you talking about exactly? JS event on a DOM node, or Java event on a View?
It is my mistake.. Attached proper APK.

1. JS event on a DOM node
WebViewSampleApp.apk
1.5 MB Download
Project Member

Comment 8 by sheriffbot@chromium.org, Jul 11 2017

Cc: boliu@chromium.org
Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "boliu@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 9 by cma...@chromium.org, Nov 17 2017

tobiasjs@ and boliu@ can you look at the proper apk in comment 7?
Cc: paulmiller@chromium.org
Owner: boliu@chromium.org
Bo, is WebView's behavior actually wrong here? I tried the same page in Chrome but Chrome doesn't generate the initial focus event so it's hard to compare. But it doesn't seem so strange that changing focus from within a focus change event would generate a new focus change event.

Imagining we don't change WebView's behavior, I would work around this by 1) using an <input type="text" autofocus> instead of <div contenteditable="true">. That would be more elegant anyway, and wouldn't require JavaScript. Or 2) writing my JavaScript to be aware of the 2nd event. (I don't know what "internal logic" this is breaking for you, so I don't know how feasible that is.)
Status: Assigned (was: Unconfirmed)

Sign in to add a comment