TextField editing causes disturbance to BrowserComponent

11 views
Skip to first unread message

P5music

unread,
Jul 8, 2021, 6:21:47 AM7/8/21
to CodenameOne Discussions
My app features a BrowserComponent where text is edited and it is also possible that material icons are displayed as images inside the BC.

The images are created as base64 data and injected as IMG tags.
It works, but there is something very strange happening.

The user experience is the following (iOS simulator, iOS 14, iOS 12):

-entering the editable area inside the BC
-clicking one button outside the BC to inject the image at the caret position
-the button has a listener, and when the method is executed the some javascript is executed
-the javascript detects the caret position and calls a callback.success method that opens a dialog (it's a special class CommandDialog) with confirmation buttons and a TextField.

now
two possible scenarios are experienced:
1-the user hits the OK button and the image is correctly injected with another javascript command

2-the user edits the TextField or just enters it (click inside) and the image is not injected, so I think the javascript command is uneffective, or the selection range is lost (the care position is in that range javascript object)

When entering the textfield I see that something happens in the layout, maybe it is recalculated, I notice slight movement of some buttons.

Are you aware or guessing of some problems that the TextField can cause to the described workflow? What disturbance is made to the BC, just when the TextField is entered?

This issue is not present when testing on the CN1 simulator. Images are always correctly injected despite even editing the TextField.

Thanks in advance

Shai Almog

unread,
Jul 8, 2021, 11:19:57 PM7/8/21
to CodenameOne Discussions
I'm guessing there's an exception in the JavaScript side. Ideally you would connect to the iOS webkit debugger on the device to see that. Haven't tried this: https://stackoverflow.com/questions/25871586/how-to-debug-javascript-code-inside-a-wkwebview

P5music

unread,
Jul 9, 2021, 5:19:13 AM7/9/21
to CodenameOne Discussions
It was not necessary to debug the WKWebView, as it seems when the BC (aka the WKWebView) loses focus the editing range is lost. The editing in the TextField causes the loss of focus, of course.
It is reasonable, so although this issue is not encountered in the CN1 simulator, it is better to manage the selection range that corresponds to the caret position  (in both cases that a text-selection is made or not) using a global JS variable to have the range when it will be needed. 

Regards
Reply all
Reply to author
Forward
0 new messages