Add scripts correctly in Field.prototype.setAction (PR 12569 follow-up) - #21691
Merged
Merged
Conversation
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 15:38 — with
GitHub Actions
Inactive
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #21691 +/- ##
=======================================
Coverage 90.00% 90.00%
=======================================
Files 263 263
Lines 66861 66861
=======================================
Hits 60178 60178
Misses 6683 6683
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Snuffleupagus
marked this pull request as ready for review
August 2, 2026 16:08
Contributor
|
You can add a this test: diff --git a/test/unit/scripting_spec.js b/test/unit/scripting_spec.js
index 3e7b133ce..22eacaa9d 100644
--- a/test/unit/scripting_spec.js
+++ b/test/unit/scripting_spec.js
@@ -363,6 +363,80 @@ describe("Scripting", function () {
});
});
+ it("should trigger an event added with setAction", async () => {
+ const refId = getId();
+ const data = {
+ objects: {
+ field: [
+ {
+ id: refId,
+ value: "",
+ actions: {},
+ type: "text",
+ },
+ ],
+ },
+ appInfo: { language: "en-US", platform: "Linux x86_64" },
+ calculationOrder: [],
+ };
+ sandbox.createSandbox(data);
+
+ await myeval(
+ `(this.getField("field").setAction("test", 'event.source.value = "abc";'), 0)`
+ );
+
+ await sandbox.dispatchEventInSandbox({
+ id: refId,
+ value: "",
+ name: "test",
+ willCommit: true,
+ });
+
+ expect(send_queue.has(refId)).toBeTrue();
+ expect(send_queue.get(refId)).toEqual({
+ id: refId,
+ value: "abc",
+ });
+ });
+
+ it("should trigger an event appended with setAction", async () => {
+ const refId = getId();
+ const data = {
+ objects: {
+ field: [
+ {
+ id: refId,
+ value: "",
+ actions: {
+ test: [`event.source.value = "a";`],
+ },
+ type: "text",
+ },
+ ],
+ },
+ appInfo: { language: "en-US", platform: "Linux x86_64" },
+ calculationOrder: [],
+ };
+ sandbox.createSandbox(data);
+
+ await myeval(
+ `(this.getField("field").setAction("test", 'event.source.value += "b";'), 0)`
+ );
+
+ await sandbox.dispatchEventInSandbox({
+ id: refId,
+ value: "",
+ name: "test",
+ willCommit: true,
+ });
+
+ expect(send_queue.has(refId)).toBeTrue();
+ expect(send_queue.get(refId)).toEqual({
+ id: refId,
+ value: "ab",
+ });
+ });
+
it("should trigger a Keystroke event and invalidate it", async () => {
const refId = getId();
const data = { |
…-up) In PR 12569 the `_actions` class-field was changed from an Object into a Map, with *most* of the code updated to reflect that. However, in the `setAction` method it's still treated as an Object which means that any added script will simply be ignored. Most likely that part of the scripting-implementation isn't being used, since this code has been "wrong" for close to six years now.
Snuffleupagus
force-pushed
the
Field-setAction-Map
branch
from
August 2, 2026 18:31
e58288e to
1f9fbc7
Compare
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
had a problem deploying
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Failure
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Snuffleupagus
temporarily deployed
to
code-coverage
August 2, 2026 18:31 — with
GitHub Actions
Inactive
Collaborator
Author
Great, thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In PR #12569 the
_actionsclass-field was changed from an Object into a Map, with most of the code updated to reflect that.However, in the
setActionmethod it's still treated as an Object which means that any added script will simply be ignored. Most likely that part of the scripting-implementation isn't being used, since this code has been "wrong" for close to six years now.Note: This was found by code inspection, and I unfortunately don't have a test-case that fails without it.