abinavseelan / react-input-trigger

React component for handling character triggers inside textareas and input fields. 🐼
MIT License
88 stars 20 forks source link

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element' #12

Open satyajeetcmm opened 5 years ago

satyajeetcmm commented 5 years ago
at getCaretCoordinates (index.js:71)
at getHookObject (react-input-trigger.js:34)
at eval (react-input-trigger.js:127)
at nrWrapper (EMNoLKlqSz:11)
jdortegar commented 5 years ago

Same issue here!

rheaditi commented 5 years ago

Hi @satyajeetcmm / @davidhabla!

We're looking into this; looks like an issue related to missing types. Can you share a small code-sandbox or example repo where we can reproduce this issue? 🙂

Thanks!

TonisPiip commented 5 years ago

I had this error when using the quill editor. I've since made changes that make it work with the quill editor. Quill doesn't use an input or textfield, rather a div and magic. However it was possible to get all the required data out using its api.

Will likely make a PR soon.

This issue definitely seems to be an issue where the logic in render isn't working right, like they've got the input wrapped in some other element.

Rather than the mapping the children elements perhaps you should get the input / input field via a natural JS method such as getElementsByTagName. Just have the rendered div have a ref and run it off it. Try to get input and failing that get textarea, then even cache it maybe.

Also I feel that the get Hook Object result should also have refs to the original event as well as this. Element

rheaditi commented 5 years ago

@CylonOven, @davidhabla, @satyajeetcmm

Hi! 👋

We hear you! We've made some changes and published a beta version for you to try out: react-input-trigger@2.0.0-beta-1.

npm install react-input-trigger@2.0.0-beta-1

For more reference on the API changes, check this and this comment.

Please let us know if it works for you!