teslamotors / informed

A lightweight framework and utility for building powerful forms in React applications
https://teslamotors.github.io/informed
MIT License
956 stars 173 forks source link

autoFocus on Input throws error: Cannot read properties of undefined (reading 'onFocus') #381

Closed denno020 closed 2 years ago

denno020 commented 2 years ago

Describe the bug When making use of the autoFocus attribute in order to force focus to a form input, an error is thrown, however the feature still seems to work.

The error thrown is: Cannot read properties of undefined (reading 'onFocus'), and it seems to come from line 362 in FormController.js

To Reproduce

This sandbox will initially just contain a Toggle button. Click on that button and the form will be rendered, which is when the autoFocus attribute will take effect. We can see that the input is actually focused as we want it to, however there is a big error that is also thrown

https://codesandbox.io/s/informed-js-autofocus-bug-1lxwt

joepuzzo commented 2 years ago

Fixed in latest version! Thanks