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 null values when parsing the domain of a locked function #2269

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

benchristel
Copy link
Member

This fixes a Perseus JSON parser error observed in production. A null value for
the upper or lower bound means infinity/unbounded, and should be allowed.

Issue: none

Test plan:

yarn test

… Allow null values when parsing the domain of a locked function on an Interactive Graph widget. A null value for the upper or lower bound means infinity/unbounded.
@benchristel benchristel self-assigned this Feb 25, 2025
@@ -259,7 +259,8 @@ const parseLockedFunctionType: Parser<LockedFunctionType> = object({
strokeStyle: parseLockedLineStyle,
equation: string,
directionalAxis: enumeration("x", "y"),
domain: optional(pairOfNumbers),
// TODO(benchristel): default domain to [null, null]?
domain: optional(pair(nullable(number), nullable(number))),
Copy link
Member Author

Choose a reason for hiding this comment

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

@nishasy would it be useful to default the domain to [null, null] if it's not present? Then the React components wouldn't need to handle the case where domain is undefined.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think @mark-fitzgerald recently updated this type, so he might have a better answer for you.

Copy link
Contributor

Choose a reason for hiding this comment

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

@benchristel - That sounds like a good plan. Thank you!

Copy link
Contributor

Size Change: +26 B (0%)

Total Size: 872 kB

Filename Size Change
packages/perseus-core/dist/es/index.js 29.9 kB +26 B (+0.09%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39.5 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 11.1 kB
packages/math-input/dist/es/index.js 78.2 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-editor/dist/es/index.js 276 kB
packages/perseus-linter/dist/es/index.js 22.8 kB
packages/perseus-score/dist/es/index.js 20.6 kB
packages/perseus/dist/es/index.js 367 kB
packages/perseus/dist/es/strings.js 6.74 kB
packages/pure-markdown/dist/es/index.js 4.14 kB
packages/simple-markdown/dist/es/index.js 13.1 kB

compressed-size-action

Copy link
Contributor

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (d0f1297) and published it to npm. You
can install it using the tag PR2269.

Example:

pnpm add @khanacademy/perseus@PR2269

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR2269

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants