Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web: DateInput onInput: Event is not InputEvent #635

Closed
hfhbd opened this issue May 4, 2021 · 3 comments
Closed

Web: DateInput onInput: Event is not InputEvent #635

hfhbd opened this issue May 4, 2021 · 3 comments
Assignees
Labels

Comments

@hfhbd
Copy link
Contributor

hfhbd commented May 4, 2021

If you have:

Input(type = InputType.DateTimeLocal, attrs = {
    onInput {
        val event = it.nativeEvent
    }
})

then onInput will always fail with a ClassCastException, because https://github.com/JetBrains/androidx/blob/107c4ac00bb4c99f29b203d71738ae7cd00c6c75/compose/web/src/jsMain/kotlin/androidx/compose/web/attributes/WrappedEventListener.kt#L150
will always cast it to InputEvent.

In Chrome and Safari, the event is type of Event, not InputEvent.
Bildschirmfoto 2021-05-04 um 19 24 00
Bildschirmfoto 2021-05-04 um 19 23 47

Safari: Version 14.1 (16611.1.21.161.6)
Chrome: Version 90.0.4430.93 (Offizieller Build) (x86_64)
macOS: 11.3.1 (20E241)

Sample Project: https://github.com/hfhbd/ComposeTodo

@hfhbd hfhbd changed the title Web: DateInput Event is not InputEvent Web: DateInput onInput: Event is not InputEvent May 4, 2021
@olonho olonho added the web label May 4, 2021
@eymar
Copy link
Collaborator

eymar commented May 5, 2021

Hi @hfhbd, thanks for reporting this issue.

it's possible to workaround this problem:

Input(
        type = InputType.DateTimeLocal,
        attrs = {
            addEventListener("input") { 
                val event = it.nativeEvent // nativeEvent is of type `Event `
            }
        }
    )

Let me know if this helps.

In general, we want to have accurately typed events. So we'll keep on improving it.

@hfhbd
Copy link
Contributor Author

hfhbd commented May 5, 2021

@eymar Thanks, it helped, was to easy to find :) After fixing this, the next button bug appears.

@eymar
Copy link
Collaborator

eymar commented Jun 29, 2021

fixed in 0.5.0-build228

@eymar eymar closed this as completed Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants