Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError: Argument 1 of Window.getComputedStyle does not implement interface Element. #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TonisPiip
Copy link

Fix for issue #12 and likely #10

The issue is that if textarea / input isn't a direct child to the component it will send a react component to getCaretCoordinates

Solution for getting the correct element,
1st: with prop getter method getElement,
2nd: Already existing method of children maping / cloning, do check for it being either a input text area
3ed: finding first occurrence of an input or textarea element.

I wanted to have some warning in case there's multple, but linting forbade it. Also linting didn't like Element being used before it was Defined, despite it being a preexisting definition...,

Also Why the timeouts with 0ms?
With my fork where I'm using quill, I need to add ~1-5 ms to have quill update the cursor positon before the triger evaluates the position, but I don't get a reason for it now.

1st: with prop getter method getElement,
2nd: Already existing method of children maping / cloning, do check for it being either a input text area
3ed: finding first occurrence of an input or textarea element.

I wanted to have some warning in case there's multple, but linting forbade it. Also linting didn't like Element being used before it was Defined, despite it being a preexisting definition...,
@TonisPiip
Copy link
Author

TonisPiip commented Jun 8, 2019

https://codesandbox.io/s/primereact-test-i1fxh

I made this codebox to test with a component that has an input inside.. however it seems codesandbox isn't loading the right fork... might be getting it form npm still... very odd... I need to get to sleep...

UPDATE:
Tried again to have codesandbox run off my branch but it always seems t error out or used some cached version of the current NPM build.
If you save it as a zip and run npm install; npm run start you can see that it works if you open the console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant