From f1f8ee47ff39cc99c9d016037194a500542e6004 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 7 Sep 2025 18:35:17 +0200 Subject: [PATCH] Fix the rendering of XFA rich text in popup annotations Before the introduction of the `renderRichText` helper function we exclusively used `this.#html` for XFA rich text and exclusively used `this.#contentsObj` for plain text. However, after the refactoring we tried to access `this.#contentsObj.dir` in both cases, which fails for XFA rich text because `this.#contentsObj` is `null` in that case. This commit fixes the issue by using optional chaining to make sure we don't try to access non-existent `this.#contentsObj` properties, which makes the `must update an existing annotation and show the right popup` freetext integration pass again. Fixes #20237. Fixes 35c90984. --- src/display/annotation_layer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index 912349361..0fefe94be 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -2494,7 +2494,7 @@ class PopupElement { renderRichText( { html: this.#html || this.#contentsObj.str, - dir: this.#contentsObj.dir, + dir: this.#contentsObj?.dir, className: "popupContent", }, popup