1

I'm trying to select the text of an input field using Fable.React. In js it can be done like this, but trying the same in Fable doesn't compile:

input [                         
        Type "text"
        OnFocus(fun e -> e.target.select())
      ]

How can I select the text in an input field when it is focused using Fable.React ?

severin
  • 5,203
  • 9
  • 35
  • 48

1 Answers1

3

The solution is to cast event.target first:

OnFocus(fun e -> 
          let target = e.target :?> Browser.HTMLInputElement
          target.select()
        )
severin
  • 5,203
  • 9
  • 35
  • 48