diff --git a/src/core/annotation.js b/src/core/annotation.js index 6f6c533e1..710551639 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -1532,6 +1532,8 @@ class WidgetAnnotation extends Annotation { } } + assert(typeof value === "string", "Expected `value` to be a string."); + value = value.trim(); if (value === "") { diff --git a/src/scripting_api/event.js b/src/scripting_api/event.js index c57f3ddae..f4036bb26 100644 --- a/src/scripting_api/event.js +++ b/src/scripting_api/event.js @@ -191,7 +191,7 @@ class EventDispatcher { let formattedValue = null; if (this.runActions(source, source, event, "Format")) { - formattedValue = event.value; + formattedValue = event.value?.toString?.(); } source.obj._send({ @@ -296,7 +296,7 @@ class EventDispatcher { savedValue = event.value = target.obj.value; let formattedValue = null; if (this.runActions(target, target, event, "Format")) { - formattedValue = event.value; + formattedValue = event.value?.toString?.(); } target.obj._send({