textfields: fix very long words not causing growY to be calculated correctly

pull/3360/head
Mime Čuvalo 2024-04-04 11:39:55 +01:00
rodzic 00d5400e15
commit a590e1ddb5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: BA84499022AC984D
1 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -318,8 +318,17 @@ function getGrowY(editor: Editor, shape: TLNoteShape, prevGrowY = 0) {
if (fontSizeAdjustment <= 14) {
// Too small, just rely now on CSS `overflow-wrap: break-word`
// We need to recalculate the text measurement here with break-word enabled.
const nextTextSizeWithOverflowBreak = editor.textMeasure.measureText(shape.props.text, {
...TEXT_PROPS,
fontFamily: FONT_FAMILIES[shape.props.font],
fontSize: fontSizeAdjustment,
maxWidth: NOTE_SIZE - PADDING * 2,
})
nextHeight = nextTextSizeWithOverflowBreak.h + PADDING * 2
break
}
if (nextTextSize.scrollWidth.toFixed(0) === nextTextSize.w.toFixed(0)) {
break
}