diff --git a/.changeset/two-pumpkins-add.md b/.changeset/two-pumpkins-add.md new file mode 100644 index 000000000..e46e708b4 --- /dev/null +++ b/.changeset/two-pumpkins-add.md @@ -0,0 +1,5 @@ +--- +'@antv/g-lite': patch +--- + +fix: rendering error when line break appears at the beginning of text diff --git a/packages/g-lite/src/services/TextService.ts b/packages/g-lite/src/services/TextService.ts index 52320f7de..bbc5dcd27 100644 --- a/packages/g-lite/src/services/TextService.ts +++ b/packages/g-lite/src/services/TextService.ts @@ -380,7 +380,7 @@ export class TextService { } // Backspace from line's end. - const currentLineLength = lines[lineIndex].length; + const currentLineLength = lines[lineIndex] ? lines[lineIndex].length : 0; let lastLineWidth = 0; let lastLineIndex = currentLineLength; for (let i = 0; i < currentLineLength; i++) {