malte-wessel / react-textfit

React component to fit headlines and paragraphs into elements
http://malte-wessel.github.io/react-textfit/
MIT License
469 stars 143 forks source link

Font size doesn't update, when the height of the div is reduced. #83

Open Johannes5 opened 3 years ago

Johannes5 commented 3 years ago

Demo video: https://www.loom.com/share/e1a54f0ee4ac4d6c93fedf24c100ec8d

When the text length changes from a length spanning multiple lines, to a smaller text requiring only one line, the font size doesn't update. It will keep its previous font size until the length of the incoming text spans more than one line and shifts the height of the div back to i's maxHeight.

the API is used like this title={(<Textfit max={20}> {article.title} </Textfit>)}

Johannes5 commented 3 years ago

it might be worth noting, that inserting window.dispatchEvent(new CustomEvent('resize')); (as suggested by @ShaMan123 in #82 ) into the component forces everything to be in one line