From 1f9f2726e060a1860d56c943291356f6ecfb81c8 Mon Sep 17 00:00:00 2001 From: Sean Lim Date: Wed, 24 Jun 2026 14:46:58 +0800 Subject: [PATCH] fix(plugin-annotation): mark FreeText as editing on input so blur doesn't drop changes handleBlur early-returns unless editingRef is set, and the ref was only raised inside the isEditing effect. After a blur reset the ref, further typing left it false, so the next blur skipped updateAnnotation and the typed text was lost. Set editingRef on every onInput so a later blur always saves the content. Applies to both FreeText and CalloutFreeText. --- .changeset/fancy-oranges-clap.md | 5 +++++ .../src/shared/components/annotations/callout-free-text.tsx | 5 +++++ .../src/shared/components/annotations/free-text.tsx | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 .changeset/fancy-oranges-clap.md diff --git a/.changeset/fancy-oranges-clap.md b/.changeset/fancy-oranges-clap.md new file mode 100644 index 000000000..83dd29530 --- /dev/null +++ b/.changeset/fancy-oranges-clap.md @@ -0,0 +1,5 @@ +--- +'@embedpdf/plugin-annotation': patch +--- + +Fix FreeText/CalloutFreeText losing typed text when edited after non-isEditing blur diff --git a/packages/plugin-annotation/src/shared/components/annotations/callout-free-text.tsx b/packages/plugin-annotation/src/shared/components/annotations/callout-free-text.tsx index fe6cbd672..646a32209 100644 --- a/packages/plugin-annotation/src/shared/components/annotations/callout-free-text.tsx +++ b/packages/plugin-annotation/src/shared/components/annotations/callout-free-text.tsx @@ -136,6 +136,10 @@ export function CalloutFreeText({ }); }; + const handleInput = () => { + editingRef.current = true; + }; + const width = rect.size.width * scale; const height = rect.size.height * scale; const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale); @@ -261,6 +265,7 @@ export function CalloutFreeText({ { + editingRef.current = true; + }; + return (