Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the 'key' field of Radio widgets to be null #2300

Merged
merged 3 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/early-swans-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus-core": patch
---

Bugfix: allow the 'key' field of Radio widgets to be null when parsing Perseus JSON
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,21 @@ describe("parseRadioWidget", () => {
),
);
});

it("allows a null key", () => {
const widget = {
type: "radio",
key: null,
graded: true,
version: {
major: 2,
minor: 0,
},
options: {
choices: [],
},
};

expect(parse(widget, parseRadioWidget)).toEqual(success(widget));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function parseWidgetWithVersion<
graded: optional(boolean),
alignment: optional(string),
options: parseOptions,
key: optional(number),
key: optional(nullable(number)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to your PR, but data-schema says key is:

Only used by interactive child widgets (line, point, etc) to identify the components

Any sense for why Radio has a value for this?

version: parseVersion,
});
}
Loading