Skip to content

Document/webview missing browser events after navigation #124

Description

@harmdewit

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();
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions