Assertion failed: Input argument is not an HTMLInputElement

04/15/20191 Min Read — In JavaScript, React.js

I have a form input text field and press the enter key to submit the form. I get an error "Assertion failed: Input argument is not an HTMLInputElement".

Assertion failed: Input argument is not an HTMLInputElement
    getFormProfile @ onloadwff.js:71
    setFieldValue @ onloadwff.js:71
    formKeydownListener @ onloadwff.js:71
onloadwff.js:71 Uncaught TypeError: Cannot read property 'type' of undefined
    at e.setFieldValue (onloadwff.js:71)
    at HTMLFormElement.formKeydownListener (onloadwff.js:71)
    setFieldValue   @   onloadwff.js:71
    formKeydownListener @   onloadwff.js:71

I originally thought that I had an error in my input field, perhaps some HTML code was wrong?

But apparently the Lastpass Chrome Extension is the culprit. You can fix it by disabling the extension.

I found an GitHub issue where someone used event.stopPropagation() to correct the event handling function.
The idea is that calling you don't let the event bubble up to the top of the DOM tree and thus Lastpass won't have access to it and send out the error message.

(From PurelyFunctional.tv):

You should be familiar with the event propagation model of the DOM. Basically, when an event fires on a DOM node, the handler on that node is called. Then the handler is called on its parent. Then on its parent, all the way up to the top of the DOM tree.

This hasn't worked for me, though.

Further Reading