Skip to content

Commit 8933fb2

Browse files
AntikodeAntikode
authored andcommitted
fix: fill-form.js optionlist fields silently discarded an explicit clear-all-selections action
Skip-if-untouched guard checked `selected.length === 0` unconditionally, which also fired when a user explicitly deselected every option in a field that DID start with a PDF-authored selection (indistinguishable from an untouched field once nothing remains selected). The pre-existing `unchanged` comparison already correctly handles the untouched case (including both-empty), so the redundant length check only ever caused harm. Same bug class as #330's dropdown fix, applied to optionlist fields.
1 parent d2745aa commit 8933fb2

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

fill-form.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,15 @@ async function fillForm() {
351351
const initialSelected = f.selected || [];
352352
const unchanged =
353353
selected.length === initialSelected.length && selected.every((v) => initialSelected.includes(v));
354-
// Same reasoning as dropdown: skip when nothing is selected (matches prior
355-
// behavior) or when the selection set is unchanged from the PDF's own
356-
// current value, so an untouched field never re-triggers assertEncodable().
357-
if (selected.length === 0 || unchanged) return;
354+
// Skip only when the selection set is unchanged from the PDF's own current
355+
// value (this already covers "untouched, both empty" — an unselected field
356+
// that started with no selection has selected.length === initialSelected.length
357+
// === 0, so `unchanged` is true). The old code also unconditionally skipped
358+
// whenever `selected.length === 0`, which silently discarded a user's
359+
// explicit action to deselect every option in a field that DID start with a
360+
// selection — indistinguishable from "never touched" once nothing remains
361+
// selected, the same ambiguity already fixed for dropdown fields above.
362+
if (unchanged) return;
358363
selected.forEach((value) => assertEncodable(value, f.name));
359364
field.select(selected);
360365
filledCount++;

0 commit comments

Comments
 (0)