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

Trouble setting onBeforeInput handler #688

Open
malcolmredheron opened this issue Dec 20, 2023 · 2 comments
Open

Trouble setting onBeforeInput handler #688

malcolmredheron opened this issue Dec 20, 2023 · 2 comments

Comments

@malcolmredheron
Copy link

I'd like to set an onBeforeInput handler on a content-editable div that I have. Since slinky.web.html doesn't contain an onBeforeInput subclass of Attr, I figured that I'd just make the AttrPair myself:

      new slinky.core.AttrPair[_onInput_attr.type]("onBeforeInput", (e: slinky.core.SyntheticEvent[Nothing, org.scalajs.dom.Event]) =>
        dom.console.log("slinky attrpair onBeforeInput", e.nativeEvent)
      )

https://github.com/malcolmredheron/scalajs-slinky-beforeinput-event-type/blob/main/src/main/scala/testvite/Main.scala shows that if I handle onInput this way, or use addEventListener to handle "beforeinput" then in both cases I get the expected InputEvent.

Where is the InputEvent coming from? Is Slinky making it?

@shadaj
Copy link
Owner

shadaj commented Dec 25, 2023

According to https://stackoverflow.com/questions/68108411/react-how-to-use-event-data-in-onbeforeinput-handler-without-typescript-error, the event type differs between browsers, so I wonder if React is doing something funky to normalize events here. Regardless, Slinky doesn't do anything with events, it just passes them through, so not super sure what's going on here.

@malcolmredheron
Copy link
Author

malcolmredheron commented Dec 27, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants