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

Chrome 66 ubuntu : caret height value is NaN #48

Open
aiibe opened this issue Apr 24, 2018 · 2 comments
Open

Chrome 66 ubuntu : caret height value is NaN #48

aiibe opened this issue Apr 24, 2018 · 2 comments

Comments

@aiibe
Copy link

aiibe commented Apr 24, 2018

getCaretCoordinates(event.target, event.target.selectionEnd) returns { top: 6, left: 10, height: NaN } on Chrome 66. On Firefox, it returns { top: 6, left: 10, height: 31 }

@frnsys
Copy link

frnsys commented Jun 25, 2018

I had the same issue, and it turns out because the computed lineHeight value (which is what textarea-caret uses for the caret height) was returned as normal rather than a numerical value. I worked around this by specifically setting a line-height value for my textarea, e.g. line-height: 1.2.

@anotherCoward
Copy link

anotherCoward commented Dec 9, 2018

I was running into the same issue, but i prevented it by adding

  span.style.all = 'unset'; // make sure everything is applied from the div, not from CSS selectors, not cross browser compatible :(
  span.style.lineHeight = '1em'; // set the line-height relative to the div

(check https://developer.mozilla.org/de/docs/Web/CSS/all)
right after creating it and modifying the result to:

height: parseInt(getComputedStyle(span).lineHeight) // get the pixelated line-height even if it is "normal"

Now it returns 16 instead of NaN on Chrome.

Greetings

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

No branches or pull requests

3 participants