question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect initial height when font-size isn't the initial value

See original GitHub issue

I’d like to create textareas with two different font-size. The problem is fixed after typing something.

Apply _resizeComponent() with setTimeout inside componentDidMount fixes de problem but I don’t now if this is the best solution:

_proto.componentDidMount = function componentDidMount() {
  [...]
  setTimeout(() => this._resizeComponent())
  [...]
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, Aug 15, 2018

That is because aphrodite does not inject styles immediately but rather it uses some kind of scheduling - https://github.com/Khan/aphrodite/blob/62ee2f0a39f10be75322dc0f77d1346e9731ffbf/src/inject.js#L163-L178

We cannot work around this in here, the timing of the injection is nondeterministic - you have to find hacky way to solve this for your case. Maybe you can call flushToStyleTag in some react hook before Textarea’s componentDidMount gets called? You probably would have to do smth like

someHookInSomeComponent() {
  css(styles.bigFont)
  flushToStyleTag()
}

because css call is actually queuing the style insertion.

0reactions
Andaristcommented, Aug 24, 2018

No problem, going to close the issue as solved 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Line height default value if font size is 100% - Stack Overflow
Depends on the user agent. Desktop browsers (including Firefox) use a default value of roughly 1.2 , depending on the element's font-family ....
Read more >
Deep dive CSS: font metrics, line-height and vertical-align
An introduction to the inline formatting context. Explores line-height and vertical-align properties, as well as the font metrics. Understand how text is ...
Read more >
font-size - CSS: Cascading Style Sheets - MDN Web Docs
The font-size CSS property sets the size of the font. Changing the font size also updates the sizes of the font size-relative <length>...
Read more >
px - em - % - pt - keyword | CSS-Tricks
Em's aren't just for fonts, it's a unit of measure that you can use for any other length (height, width, etc). Elastic width...
Read more >
How to Change Font Size in CSS - HubSpot Blog
There are several values you can use to define the font-size property. ... Note that in HTML the default font size is 16...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found