From 118c83a5082ca563434f779b11bba965516d4ce9 Mon Sep 17 00:00:00 2001 From: wang1212 Date: Wed, 18 Dec 2024 17:57:35 +0800 Subject: [PATCH] fix: rendering error when line break appears at the beginning of text --- .changeset/two-pumpkins-add.md | 5 +++++ packages/g-lite/src/services/TextService.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/two-pumpkins-add.md 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++) {