-
Notifications
You must be signed in to change notification settings - Fork 30
Description
In our application we're using barcode scanners to receive data input and form submission using a single scan. This basically means that we're listening to keyboard events on the document to populate inputs and submit forms.
We noticed that we're missing keydown events on the document after navigation.
When scanning a barcode the listener on the document (keydown@document) doesn't get triggered.
Only after touching the screen all previously expected events are triggered.
It seems like the webview is missing focus after navigation and that it only gets the focus after touching the screen. For normal keyboard input via the onscreen virtual keyboard you don't notice this since you're already touching the screen, setting the focus. Also on desktop browsers the document keeps the focus on navigation.
As a workaround I'm focussing the webview manually by customizing the default fragment:
package nl.greenwms
import dev.hotwire.navigation.fragments.HotwireWebFragment
import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink
import android.util.Log
import dev.hotwire.core.turbo.webview.HotwireWebView
@HotwireDestinationDeepLink(uri = "hotwire://fragment/web")
open class WebFragment : HotwireWebFragment() {
override fun onWebViewAttached(webView: HotwireWebView) {
webView.requestFocus();
}
}