Skip to content

Check the radio button a script selected before its page rendered (issue 22393) - #22394

Open
yhay81 wants to merge 1 commit into
mozilla:masterfrom
yhay81:radio-script-value-before-render
Open

yhay81 wants to merge 1 commit into
mozilla:masterfrom
yhay81:radio-script-value-before-render

Conversation

@yhay81

@yhay81 yhay81 commented Oct 30, 2026

Copy link
Copy Markdown

Fixes #22393.

When a script sets the value of a radio group whose page isn't rendered yet, the value goes into the annotation storage, and each radio button reads it when it renders. Two things went wrong there:

  • PDFScriptingManager.#updateFromSandbox stored the same detail object for every widget of the field, and AnnotationStorage.setValue updates the object it holds, so the boolean that the first radio button stored under its own id became the value of all of its siblings.
  • RadioButtonWidgetAnnotationElement.render turned the stored export value into value !== data.buttonValue, so the button whose export value was set rendered unchecked and the others checked.

The first radio button showed checked, and every widget stored false, so the form saved no selection. Each widget now gets its own copy, and a radio button is checked when the stored value is its export value, as in its updatefromsandbox handler. Neither change is enough alone: with only the comparison fixed, the first radio button stores false into the shared object, and no button is checked.

The integration test clicks a push button on page 1 of issue22393.pdf whose action sets the radio group on page 5, scrolls to page 5, and expects only the selected button to be checked and stored as true. Locally, without this change, it fails in Chrome 156 and Firefox Nightly 161. With it, the integration tests in annotation_spec.mjs and scripting_spec.mjs pass in both, except "must check that an infinite loop is not triggered", which times out in Firefox Nightly 161 on master too.

🤖 Generated with Claude Code

…sue 22393)

A value that a script sets on a field whose widgets aren't rendered yet
goes into the annotation storage, and each radio button reads it when
it renders. Two things went wrong there:

- `PDFScriptingManager` stored the same object for every widget of the
  field, and `AnnotationStorage.setValue` updates the object it holds,
  so the boolean that the first radio button stored under its own id
  became the value of all of its siblings.
- `RadioButtonWidgetAnnotationElement` turned the stored export value
  into `value !== data.buttonValue`, so the button whose export value
  was set rendered unchecked and the others checked.

The first radio button showed checked, and every widget stored `false`.
Each widget now gets its own copy, and a radio button is checked when
the stored value is its export value, as in its `updatefromsandbox`
handler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: A radio group set by a script before its page renders shows the wrong button checked, and every button stores false

2 participants