-
Notifications
You must be signed in to change notification settings - Fork 357
InputNumber: renderer user input state #2589
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
Merged
Merged
Conversation
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
Size Change: -13 B (0%) Total Size: 473 kB
ℹ️ View Unchanged
|
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (db967a1) and published it to npm. You Example: pnpm add @khanacademy/perseus@PR2589 If you are working in Khan Academy's frontend, you can run the below command. ./tools/bump_perseus_version.js -t PR2589 If you are working in Khan Academy's webapp, you can run the below command. ./dev/tools/bump_perseus_version.js -s n -t PR2589 |
mark-fitzgerald
approved these changes
Jun 16, 2025
handeyeco
added a commit
that referenced
this pull request
Jun 24, 2025
## Summary: Issue: [LEMS-3208](https://khanacademy.atlassian.net/browse/LEMS-3208) Edit see the ticket for full context. **tl;dr: I need user input to be outside the chunk of state that Renderer stores arbitrary widget state in** (currently it's a mash of render props, user input, and whatever else widgets want to shove in there). This ticket is the shared changes of this work - things that multiple widgets need. For the most part, I tried to have the other PRs _only_ affect things that are _specific_ to the individual widget. Anything outside of the immediate scope of the widget went into this PR. The main ideas: - Renderer now has `userInput` state which is a `UserInputMap` - `UniversalWidgetProps` now passes `userInput` and `handleUserInput` down to components for them to consume - `WidgetExports` has some new optional APIs: - `getUserInputFromSerializedState` for restoring serialized state - `getStartUserInput` for initializing user input - `getCorrectUserInput` for static widgets - Marked a bunch of things as deprecated Note that besides some cleanup, no tests were harmed in the making of this PR. It's backwards compatible with our old way of doing things. --- Reviewers: handeyeco, benchristel, SonicScrewdriver, jeremywiebe, ivyolamit, mark-fitzgerald, anakaren-rojas, nishasy Child PRs: - [Categorizer](#2572) - [CSProgram](#2584) - [Dropdown](#2568) - [Expression](#2569) - [FreeResponse](#2585) - [Grapher](#2596) - [IFrame](#2582) - [InputNumber](#2589) - [InteractiveGraph](#2598) - [LabelImage](#2577) - [Matcher](#2575) - [Matrix](#2581) - [MockWidget](#2586) - [NumberLine](#2573) - [NumericInput](#2571) - [Orderer](#2592) - [Plotter](#2588) - [Sorter](#2578) - [Table](#2587) [LEMS-3208]: https://khanacademy.atlassian.net/browse/LEMS-3208?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ Author: handeyeco Required Reviewers: Approved By: SonicScrewdriver, jeremywiebe Checks: ✅ 8 checks were successful Pull Request URL: #2566
An error occurred while trying to automatically change base from
renderer-user-input-core
to
feature/renderer-user-input
June 24, 2025 17:08
bc38d99
to
db967a1
Compare
handeyeco
added a commit
that referenced
this pull request
Jul 2, 2025
This is an integration branch for landing approved PRs on. ## Summary: This PR includes the following commits: - Renderer: separate user input state from render props state (#2566) - Dropdown: renderer user input state. (#2568) - Expression: renderer user input state (#2569) - NumericInput: renderer user input state (#2571) - Categorizer: renderer user input state (#2572) - NumberLine: renderer user input state (#2573) - Matcher: renderer user input state (#2575) - Sorter: renderer user input state (#2578) - Matrix: renderer user input state (#2581) - IFrame: renderer user input state (#2582) - CSProgram: renderer user input state (#2584) - FreeResponse: renderer user input state (#2585) - MockWidget: renderer user input state (#2586) - Table: renderer user input state (#2587) - Plotter: renderer user input state (#2588) - InputNumber: renderer user input state (#2589) - Orderer: renderer user input state (#2592) - Grapher: renderer user input state (#2596) - InteractiveGraph: renderer user input state (#2598) - LabelImage: renderer user input state (#2577) - Clean up some change handler stuff (#2644) - LEMS-3247: NumberLine inequality regression (#2645) - Bugfix: Plotter dot graph crashing (#2651) - Bugfix: static switch not working in editor (#2652) - LEMS-3257: Fix IG regression regarding user input (#2654) - Bugfix: restore support for static in IG and Plotter (#2661) Issue: LEMS-3208 ## Test plan: Author: handeyeco Reviewers: SonicScrewdriver, ivyolamit, mark-fitzgerald, anakaren-rojas, nishasy, benchristel, Myranae Required Reviewers: Approved By: SonicScrewdriver Checks: ✅ 14 checks were successful Pull Request URL: #2642
Merged
handeyeco
pushed a commit
that referenced
this pull request
Jul 2, 2025
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @khanacademy/perseus@65.4.0 ### Minor Changes - [#2566](#2566) [`21f79b664`](21f79b6) Thanks [@handeyeco](https://github.com/handeyeco)! - Add support for `userInput` state in Renderer, new user input APIs for WidgetExport ### Patch Changes - [#2596](#2596) [`f15a4cc56`](f15a4cc) Thanks [@handeyeco](https://github.com/handeyeco)! - Grapher: use userInput/handleUserInput - [#2571](#2571) [`de05305b2`](de05305) Thanks [@handeyeco](https://github.com/handeyeco)! - NumericInput: use userInput/handleUserInput - [#2572](#2572) [`ff2cd2916`](ff2cd29) Thanks [@handeyeco](https://github.com/handeyeco)! - Categorizer: use userInput/handleUserInput - [#2575](#2575) [`f84722b44`](f84722b) Thanks [@handeyeco](https://github.com/handeyeco)! - Matcher: use userInput/handleUserInput - [#2661](#2661) [`4573c0476`](4573c04) Thanks [@handeyeco](https://github.com/handeyeco)! - Bugfix: restore support for static in IG and Plotter - [#2588](#2588) [`380720116`](3807201) Thanks [@handeyeco](https://github.com/handeyeco)! - Plotter: use userInput/handleUserInput - [#2589](#2589) [`e7353c696`](e7353c6) Thanks [@handeyeco](https://github.com/handeyeco)! - InputNumber: use userInput/handleUserInput - [#2577](#2577) [`e2ed14e58`](e2ed14e) Thanks [@handeyeco](https://github.com/handeyeco)! - LabelImage: use userInput/handleUserInput - [#2578](#2578) [`bcf4fd541`](bcf4fd5) Thanks [@handeyeco](https://github.com/handeyeco)! - Sorter: use userInput/handleUserInput - [#2569](#2569) [`1eadde57b`](1eadde5) Thanks [@handeyeco](https://github.com/handeyeco)! - Expression: use userInput/handleUserInput - [#2586](#2586) [`8b63ac0ed`](8b63ac0) Thanks [@handeyeco](https://github.com/handeyeco)! - MockWidget: use userInput/handleUserInput - [#2584](#2584) [`e175b8bc7`](e175b8b) Thanks [@handeyeco](https://github.com/handeyeco)! - CSProgram: use userInput/handleUserInput - [#2651](#2651) [`516aea734`](516aea7) Thanks [@handeyeco](https://github.com/handeyeco)! - Bugfix: Plotter dot graph crashing after user input refactor - [#2644](#2644) [`f51181adc`](f51181a) Thanks [@handeyeco](https://github.com/handeyeco)! - Cleanup some ChangeHandler and Changeable use - [#2573](#2573) [`3a3f5233b`](3a3f523) Thanks [@handeyeco](https://github.com/handeyeco)! - NumberLine: use userInput/handleUserInput - [#2585](#2585) [`4af4b1f23`](4af4b1f) Thanks [@handeyeco](https://github.com/handeyeco)! - FreeResponse: use userInput/handleUserInput - [#2592](#2592) [`091c25ee6`](091c25e) Thanks [@handeyeco](https://github.com/handeyeco)! - Orderer: use userInput/handleUserInput - [#2568](#2568) [`02af17299`](02af172) Thanks [@handeyeco](https://github.com/handeyeco)! - Dropdown: use userInput/handleUserInput - [#2652](#2652) [`508f4e5b1`](508f4e5) Thanks [@handeyeco](https://github.com/handeyeco)! - Bugfix: static switch not working in editor - [#2582](#2582) [`41fb2b215`](41fb2b2) Thanks [@handeyeco](https://github.com/handeyeco)! - IFrame: use userInput/handleUserInput - [#2654](#2654) [`3fcbddb71`](3fcbddb) Thanks [@handeyeco](https://github.com/handeyeco)! - Bugfix: IG regression related to user input and `getGradableGraph` - [#2581](#2581) [`52960e3b0`](52960e3) Thanks [@handeyeco](https://github.com/handeyeco)! - Matrix: use userInput/handleUserInput - [#2587](#2587) [`88a4f683d`](88a4f68) Thanks [@handeyeco](https://github.com/handeyeco)! - Table: use userInput/handleUserInput - [#2645](#2645) [`e3a636a73`](e3a636a) Thanks [@handeyeco](https://github.com/handeyeco)! - Bugfix: NumberLine inequality buttons didn't change inequality - [#2598](#2598) [`c58f12c72`](c58f12c) Thanks [@handeyeco](https://github.com/handeyeco)! - InteractiveGraph: use userInput/handleUserInput - Updated dependencies \[[`f15a4cc56`](f15a4cc), [`f84722b44`](f84722b), [`e2ed14e58`](e2ed14e), [`bcf4fd541`](bcf4fd5), [`f51181adc`](f51181a), [`21f79b664`](21f79b6), [`3a3f5233b`](3a3f523)]: - @khanacademy/perseus-core@16.1.1 - @khanacademy/perseus-score@7.1.10 - @khanacademy/keypad-context@3.0.23 - @khanacademy/kmath@2.0.23 - @khanacademy/math-input@26.0.12 - @khanacademy/perseus-linter@4.0.10 ## @khanacademy/keypad-context@3.0.23 ### Patch Changes - Updated dependencies \[[`f15a4cc56`](f15a4cc), [`f84722b44`](f84722b), [`e2ed14e58`](e2ed14e), [`bcf4fd541`](bcf4fd5), [`f51181adc`](f51181a), [`21f79b664`](21f79b6), [`3a3f5233b`](3a3f523)]: - @khanacademy/perseus-core@16.1.1 ## @khanacademy/kmath@2.0.23 ### Patch Changes - Updated dependencies \[[`f15a4cc56`](f15a4cc), [`f84722b44`](f84722b), [`e2ed14e58`](e2ed14e), [`bcf4fd541`](bcf4fd5), [`f51181adc`](f51181a), [`21f79b664`](21f79b6), [`3a3f5233b`](3a3f523)]: - @khanacademy/perseus-core@16.1.1 ## @khanacademy/math-input@26.0.12 ### Patch Changes - Updated dependencies \[[`f15a4cc56`](f15a4cc), [`f84722b44`](f84722b), [`e2ed14e58`](e2ed14e), [`bcf4fd541`](bcf4fd5), [`f51181adc`](f51181a), [`21f79b664`](21f79b6), [`3a3f5233b`](3a3f523)]: - @khanacademy/perseus-core@16.1.1 - @khanacademy/keypad-context@3.0.23 ## @khanacademy/perseus-core@16.1.1 ### Patch Changes - [#2596](#2596) [`f15a4cc56`](f15a4cc) Thanks [@handeyeco](https://github.com/handeyeco)! - Grapher: use userInput/handleUserInput - [#2575](#2575) [`f84722b44`](f84722b) Thanks [@handeyeco](https://github.com/handeyeco)! - Matcher: use userInput/handleUserInput - [#2577](#2577) [`e2ed14e58`](e2ed14e) Thanks [@handeyeco](https://github.com/handeyeco)! - LabelImage: use userInput/handleUserInput - [#2578](#2578) [`bcf4fd541`](bcf4fd5) Thanks [@handeyeco](https://github.com/handeyeco)! - Sorter: use userInput/handleUserInput - [#2644](#2644) [`f51181adc`](f51181a) Thanks [@handeyeco](https://github.com/handeyeco)! - Cleanup some ChangeHandler and Changeable use - [#2566](#2566) [`21f79b664`](21f79b6) Thanks [@handeyeco](https://github.com/handeyeco)! - Add support for `userInput` state in Renderer, new user input APIs for WidgetExport - [#2573](#2573) [`3a3f5233b`](3a3f523) Thanks [@handeyeco](https://github.com/handeyeco)! - NumberLine: use userInput/handleUserInput ## @khanacademy/perseus-editor@25.1.2 ### Patch Changes - [#2596](#2596) [`f15a4cc56`](f15a4cc) Thanks [@handeyeco](https://github.com/handeyeco)! - Grapher: use userInput/handleUserInput - [#2572](#2572) [`ff2cd2916`](ff2cd29) Thanks [@handeyeco](https://github.com/handeyeco)! - Categorizer: use userInput/handleUserInput - [#2588](#2588) [`380720116`](3807201) Thanks [@handeyeco](https://github.com/handeyeco)! - Plotter: use userInput/handleUserInput - [#2569](#2569) [`1eadde57b`](1eadde5) Thanks [@handeyeco](https://github.com/handeyeco)! - Expression: use userInput/handleUserInput - [#2644](#2644) [`f51181adc`](f51181a) Thanks [@handeyeco](https://github.com/handeyeco)! - Cleanup some ChangeHandler and Changeable use - [#2652](#2652) [`508f4e5b1`](508f4e5) Thanks [@handeyeco](https://github.com/handeyeco)! - Bugfix: static switch not working in editor - [#2581](#2581) [`52960e3b0`](52960e3) Thanks [@handeyeco](https://github.com/handeyeco)! - Matrix: use userInput/handleUserInput - [#2587](#2587) [`88a4f683d`](88a4f68) Thanks [@handeyeco](https://github.com/handeyeco)! - Table: use userInput/handleUserInput - [#2598](#2598) [`c58f12c72`](c58f12c) Thanks [@handeyeco](https://github.com/handeyeco)! - InteractiveGraph: use userInput/handleUserInput - Updated dependencies \[[`f15a4cc56`](f15a4cc), [`de05305b2`](de05305), [`ff2cd2916`](ff2cd29), [`f84722b44`](f84722b), [`4573c0476`](4573c04), [`380720116`](3807201), [`e7353c696`](e7353c6), [`e2ed14e58`](e2ed14e), [`bcf4fd541`](bcf4fd5), [`1eadde57b`](1eadde5), [`8b63ac0ed`](8b63ac0), [`e175b8bc7`](e175b8b), [`516aea734`](516aea7), [`f51181adc`](f51181a), [`21f79b664`](21f79b6), [`3a3f5233b`](3a3f523), [`4af4b1f23`](4af4b1f), [`091c25ee6`](091c25e), [`02af17299`](02af172), [`508f4e5b1`](508f4e5), [`41fb2b215`](41fb2b2), [`3fcbddb71`](3fcbddb), [`52960e3b0`](52960e3), [`88a4f683d`](88a4f68), [`e3a636a73`](e3a636a), [`c58f12c72`](c58f12c)]: - @khanacademy/perseus@65.4.0 - @khanacademy/perseus-core@16.1.1 - @khanacademy/perseus-score@7.1.10 - @khanacademy/keypad-context@3.0.23 - @khanacademy/kmath@2.0.23 - @khanacademy/math-input@26.0.12 - @khanacademy/perseus-linter@4.0.10 ## @khanacademy/perseus-linter@4.0.10 ### Patch Changes - Updated dependencies \[[`f15a4cc56`](f15a4cc), [`f84722b44`](f84722b), [`e2ed14e58`](e2ed14e), [`bcf4fd541`](bcf4fd5), [`f51181adc`](f51181a), [`21f79b664`](21f79b6), [`3a3f5233b`](3a3f523)]: - @khanacademy/perseus-core@16.1.1 ## @khanacademy/perseus-score@7.1.10 ### Patch Changes - [#2578](#2578) [`bcf4fd541`](bcf4fd5) Thanks [@handeyeco](https://github.com/handeyeco)! - Sorter: use userInput/handleUserInput - [#2644](#2644) [`f51181adc`](f51181a) Thanks [@handeyeco](https://github.com/handeyeco)! - Cleanup some ChangeHandler and Changeable use - [#2573](#2573) [`3a3f5233b`](3a3f523) Thanks [@handeyeco](https://github.com/handeyeco)! - NumberLine: use userInput/handleUserInput - Updated dependencies \[[`f15a4cc56`](f15a4cc), [`f84722b44`](f84722b), [`e2ed14e58`](e2ed14e), [`bcf4fd541`](bcf4fd5), [`f51181adc`](f51181a), [`21f79b664`](21f79b6), [`3a3f5233b`](3a3f523)]: - @khanacademy/perseus-core@16.1.1 - @khanacademy/kmath@2.0.23 ## @khanacademy/perseus-dev-ui@5.5.7 ### Patch Changes - Updated dependencies \[[`f15a4cc56`](f15a4cc), [`f84722b44`](f84722b), [`e2ed14e58`](e2ed14e), [`bcf4fd541`](bcf4fd5), [`f51181adc`](f51181a), [`21f79b664`](21f79b6), [`3a3f5233b`](3a3f523)]: - @khanacademy/perseus-core@16.1.1 - @khanacademy/kmath@2.0.23 - @khanacademy/math-input@26.0.12 - @khanacademy/perseus-linter@4.0.10 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Summary:
See the parent PR for more context. Part of LEMS-3208.
In #2566 I add additional APIs to let widgets consume
userInput
from a parent and to update that parent state usinghandleUserInput
, while also supporting the legacy way of storing user input (which was a combination of internal widget state and stashing state in a random blob in Renderer). This PR is part of a series of PRs that go widget-by-widget to use the new API.This is a generic summary I'm putting on each PR and not every point will be applicable to every widget, but the common themes are:
getSerializedState
andgetUserInputFromSerializedState
to keep supporting the expected results.userInput
state in Renderer. This means consuminguserInput
in the component and callinghandleUserInput
on change.transform
did something to initialize user input state, I moved the logic togetStartUserInput
.staticTransform
did something to get correct state in static widgets, I moved the logic togetCorrectUserInput
.Please see the parent PR for more information.
InputNumberEditor doesn't use InputNumber, so this shouldn't affect the editing experience