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

Text cursor not centered vertically in Safari browser #351

Open
romanr opened this issue Dec 12, 2016 · 8 comments
Open

Text cursor not centered vertically in Safari browser #351

romanr opened this issue Dec 12, 2016 · 8 comments

Comments

@romanr
Copy link

romanr commented Dec 12, 2016

Bug report

  • Package version(s): 1.3.1
  • Browser and OS versions: Safari 10.0.1, MacOS Sierra.

Steps to reproduce

  1. Type text in TextField

Actual behavior

Text cursor is not centered vertically:

screenshot 2016-12-12 15 36 21

@llorca
Copy link
Contributor

llorca commented Dec 12, 2016

That's pretty weird, the text is vertically centered. Not sure if that counts as a bug...

@romanr
Copy link
Author

romanr commented Dec 13, 2016

After some research on the web it appears like recurrent issue for Safari, mobile Safari and even Chrome.
This is fixed by setting line-height: normal in input field css:

input.pt-input.pt-fill {
    line-height: normal;
}

may also be fixed by line-height: 1; or line-height: 100%; however line-height: normal; is considered the best solution.
Let me know if you would accept PR of this.

@giladgray
Copy link
Contributor

I've noticed this issue with how Safari draws cursors--it's deeply inconsistent with other browsers.

@llorca llorca added this to the 1.5.0 milestone Dec 13, 2016
@llorca
Copy link
Contributor

llorca commented Dec 13, 2016

We've been using line-height to center the text vertically, but don't remember for which browser or specific use cases.

I'm afraid a change to line-height may break vertical centering in certain contexts, but certainly happy to take a look at this after the holiday or review any PR submitted on the matter 👍

@cmslewis
Copy link
Contributor

cmslewis commented Jan 9, 2017

@llorca - What if we just use top/bottom padding within the input? Then we can keep line-height normal in all browsers and still have the power to massage the vertical offsets of the text.

@llorca
Copy link
Contributor

llorca commented Jan 9, 2017

We could try, we didn't use padding to begin with because of the inconsistencies between browsers (we ended up with an input of 31px in some cases)

@giladgray
Copy link
Contributor

just studied github's repo search box and here's what i learned:

.centered-input-text {
  font-size: 13px;
  line-height: 20px;
}

@giladgray
Copy link
Contributor

giladgray commented Jan 10, 2017

the root cause is that our 14px font-size produces 11px-tall letters, whereas 16px font-size (large) produces 12px-tall letters. the odd height means it can't ever be centered on the whole pixel which causes the off-by-a-few issue in the screenshot above.

so a font-size that produces 10px-high letters of course solves the centering problem.
a reduced line-height solves the safari cursor rendering issue.

(see #371 for original discussion)

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

No branches or pull requests

4 participants