1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Use the original value of a field when propagating event (fixes #17540)

And avoid to not format a field when the value is 0.
This commit is contained in:
Calixte Denizet 2024-01-19 17:47:05 +01:00
parent f8e3c79cb5
commit 5732c0c54a
6 changed files with 81 additions and 8 deletions

View file

@ -220,10 +220,6 @@ class AForm {
bCurrencyPrepend
) {
const event = globalThis.event;
if (!event.value) {
return;
}
let value = this.AFMakeNumber(event.value);
if (value === null) {
event.value = "";

View file

@ -335,7 +335,7 @@ class EventDispatcher {
event.value = null;
const target = this._objects[targetId];
let savedValue = target.obj.value;
let savedValue = target.obj._getValue();
this.runActions(source, target, event, "Calculate");
if (!event.rc) {
continue;
@ -344,18 +344,23 @@ class EventDispatcher {
if (event.value !== null) {
// A new value has been calculated so set it.
target.obj.value = event.value;
} else {
event.value = target.obj._getValue();
}
event.value = target.obj.value;
this.runActions(target, target, event, "Validate");
if (!event.rc) {
if (target.obj.value !== savedValue) {
if (target.obj._getValue() !== savedValue) {
target.wrapped.value = savedValue;
}
continue;
}
savedValue = event.value = target.obj.value;
if (event.value === null) {
event.value = target.obj._getValue();
}
savedValue = target.obj._getValue();
let formattedValue = null;
if (this.runActions(target, target, event, "Format")) {
formattedValue = event.value?.toString?.();