From 9da056e00ee485d702134b5beb95a466ab051215 Mon Sep 17 00:00:00 2001 From: Eric Kaden <608341+EricKaden@users.noreply.github.com> Date: Mon, 19 Oct 2026 23:32:16 -0400 Subject: [PATCH] Forms: a later XFA script reads the highlight an earlier one set --- crates/engine/src/tests.rs | 1 + crates/engine/src/xfa.rs | 3 +++ crates/xfa/src/fixtures.rs | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 4ceefebbef..3a34b00d56 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -6116,6 +6116,7 @@ fn a_forms_layout_ready_scripts_run_once_it_is_laid_out() { let out = s.take_js_output(id); assert_eq!(out.requests, vec![js::Request::Highlight(true)], "the form turns field highlighting on: {out:?}"); assert_eq!(value(&s, "stamp"), vec!["laid out".to_string()]); + assert_eq!(value(&s, "seen"), vec!["true".to_string()], "a later script reads the highlight the root's turned on"); assert!(value(&s, "pageNo").iter().all(|v| v.is_empty()), "page numbers are the layout's: {:?}", value(&s, "pageNo")); assert!(value(&s, "note").iter().all(|v| v.is_empty()), "form:ready is another event"); // With highlighting already on, the form has nothing to ask for. diff --git a/crates/engine/src/xfa.rs b/crates/engine/src/xfa.rs index 6a9fe2a8c6..a1c4416408 100644 --- a/crates/engine/src/xfa.rs +++ b/crates/engine/src/xfa.rs @@ -636,6 +636,9 @@ impl<'a, 'b> Runner<'a, 'b> { XfaEffect::Beep => self.run.out.requests.push(Request::Beep), XfaEffect::Highlight(on) => { self.run.highlight = *on; + // The session's scripts read the setting it started with: the next script + // gets a session that reads the new one. + self.session = None; self.run.out.requests.push(Request::Highlight(*on)); } XfaEffect::Recalculate => {} diff --git a/crates/xfa/src/fixtures.rs b/crates/xfa/src/fixtures.rs index 191f5c6afe..0f8cea53f6 100644 --- a/crates/xfa/src/fixtures.rs +++ b/crates/xfa/src/fixtures.rs @@ -119,8 +119,9 @@ fn assemble(objs: Vec>) -> Vec { /// a table whose `row` (item, amount) repeats, with `addRow`, `removeRow` and `hello` buttons; /// `grand`, the calculated sum of the amounts. /// A form with `layout:ready` scripts: the root subform turns field highlighting on (as forms -/// do with `app.runtimeHighlight`), `stamp` takes a value, and `pageNo` numbers its page (left to -/// the layout). `note` has a `form:ready` script, a different event. +/// do with `app.runtimeHighlight`), `stamp` takes a value, `seen` records the highlight its script +/// reads after the root's, and `pageNo` numbers its page (left to the layout). `note` has a +/// `form:ready` script, a different event. pub fn layout_ready_template() -> String { r##" @@ -130,6 +131,7 @@ pub fn layout_ready_template() -> String { +