You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 1, 2021. It is now read-only.
I want to do simple thing. Just focus and select input field after click button. I have code like this:
[@react.component]
let make = () => {
let inputRef = React.useRef(Js.Nullable.null);
let handleSelect = _event => {
let element =
inputRef.current->Js.toOption->Belt.Option.flatMap(Webapi.Dom.HtmlInputElement.ofElement);
switch (element) {
| Some(input) =>
Webapi.Dom.HtmlInputElement.focus(input);
Webapi.Dom.HtmlInputElement.select(input);
| None => ()
};
};
<>
<input
className="new-leon-input"
type_="text"
value="abcd"
onChange={_ => ()}
ref={ReactDOMRe.Ref.domRef(inputRef)}
/>
<button onClick=handleSelect> "select"->React.string </button>
</>;
};
Compiler return a bug:
We've found a bug for you!
src/components/TestComponent.re 11:41-45
9 ┆ switch (element) {
10 ┆ | Some(input) =>
11 ┆ Webapi.Dom.HtmlInputElement.focus(input);
12 ┆ Webapi.Dom.HtmlInputElement.select(input);
13 ┆ | None => ()
This has type:
Dom.htmlElement (defined as
Dom.eventTarget_like(Dom._node(Dom._element(Dom._htmlElement(Dom._baseClass)))))
But somewhere wanted:
Webapi.Dom.HtmlInputElement.t_htmlElement (defined as
Dom.eventTarget_like(Dom._node(Dom._element(Dom._htmlElement(Dom._htmlInputElement)))))
The incompatible parts:
Dom._baseClass
vs
Dom._htmlInputElement
What is wrong in this code ? This code was working with bs-webapi 0.15.9, with newest: 0.19.1 i have an error above. Maybe there is a bug in library ?
I use bs-platform: 7.3.2
I want to do simple thing. Just focus and select input field after click button. I have code like this:
Compiler return a bug:
What is wrong in this code ? This code was working with bs-webapi 0.15.9, with newest: 0.19.1 i have an error above. Maybe there is a bug in library ?
I use bs-platform: 7.3.2