Skip to content

Commit

Permalink
fix: Modifying size update handling for multiline field in parent blo…
Browse files Browse the repository at this point in the history
…ck. (#6461)
  • Loading branch information
yamadayutaka committed Oct 3, 2022
1 parent d3447ea commit 2a2cbb4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/field_multilineinput.ts
Expand Up @@ -270,11 +270,15 @@ export class FieldMultilineInput extends FieldTextInput {
/** Updates the size of the field based on the text. */
protected override updateSize_() {
const nodes = this.textGroup_.childNodes;
const fontSize = this.getConstants()!.FIELD_TEXT_FONTSIZE;
const fontWeight = this.getConstants()!.FIELD_TEXT_FONTWEIGHT;
const fontFamily = this.getConstants()!.FIELD_TEXT_FONTFAMILY;
let totalWidth = 0;
let totalHeight = 0;
for (let i = 0; i < nodes.length; i++) {
const tspan = nodes[i] as SVGTextElement;
const textWidth = dom.getTextWidth(tspan);
const textWidth =
dom.getFastTextWidth(tspan, fontSize, fontWeight, fontFamily);
if (textWidth > totalWidth) {
totalWidth = textWidth;
}
Expand All @@ -290,9 +294,6 @@ export class FieldMultilineInput extends FieldTextInput {
const actualEditorLines = this.value_.split('\n');
const dummyTextElement = dom.createSvgElement(
Svg.TEXT, {'class': 'blocklyText blocklyMultilineText'});
const fontSize = this.getConstants()!.FIELD_TEXT_FONTSIZE;
const fontWeight = this.getConstants()!.FIELD_TEXT_FONTWEIGHT;
const fontFamily = this.getConstants()!.FIELD_TEXT_FONTFAMILY;

for (let i = 0; i < actualEditorLines.length; i++) {
if (actualEditorLines[i].length > this.maxDisplayLength) {
Expand Down

0 comments on commit 2a2cbb4

Please sign in to comment.