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

Deprecate custom ID generation APIs from Wonder Blocks #2007

Merged
merged 6 commits into from
Dec 16, 2024

Conversation

somewhatabstract
Copy link
Member

Summary:

Welcome to the Wonder Blocks 1812 Overture - a series of PRs that will deprecate and remove the custom ID generation utilities in favour of React's useId and the new Id component that is built atop of it.

This updates dependencies in Perseus to latest webapp dependencies (used the sync script for that), and includes the soon to be released Wonder Blocks that deprecates the custom ID generation utilities in favour of React's useId and the new Id component that is built atop of it.

An upcoming PR will then have the work of removing the old API uses so that we can then delete them from a future Wonder Blocks release.

NOTE: I will update this to the actual released WB before landing, once that happens. I am trying to get everything reviewed and ready to go so that when I do that release, I can get everything up-to-date quickly and correctly.

Issue: WB-1812

Test plan:

yarn test
yarn lint

@somewhatabstract somewhatabstract self-assigned this Dec 13, 2024
@somewhatabstract somewhatabstract requested a review from a team December 13, 2024 22:15
Copy link
Contributor

github-actions bot commented Dec 13, 2024

Size Change: +457 B (+0.04%)

Total Size: 1.27 MB

Filename Size Change
packages/kas/dist/es/index.js 39 kB -4 B (-0.01%)
packages/math-input/dist/es/index.js 78 kB +44 B (+0.06%)
packages/perseus-editor/dist/es/index.js 688 kB +232 B (+0.03%)
packages/perseus-linter/dist/es/index.js 22.2 kB +6 B (+0.03%)
packages/perseus/dist/es/index.js 416 kB +168 B (+0.04%)
packages/pure-markdown/dist/es/index.js 3.67 kB +11 B (+0.3%)
ℹ️ View Unchanged
Filename Size
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 4.27 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 1.48 kB
packages/perseus/dist/es/strings.js 4.12 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

Copy link
Member

@catandthemachines catandthemachines left a comment

Choose a reason for hiding this comment

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

Approved! Added note, @somewhatabstract the console errors are refering to the use of SingleSelect on answer-choices.tsx. Just update line 33 with opener: (openerProps: OpenerProps) => React.ReactElement<any>;.

Copy link
Contributor

github-actions bot commented Dec 13, 2024

npm Snapshot: Published

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

Example:

yarn add @khanacademy/perseus@PR2007

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

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

@somewhatabstract
Copy link
Member Author

Approved! Added note, @somewhatabstract the console errors are refering to the use of SingleSelect on answer-choices.tsx. Just update line 33 with opener: (openerProps: OpenerProps) => React.ReactElement<any>;.

I fixed this with what I think is a better approach that matches the intent of the broken declaration. I used PropsFor from Wonder Blocks Core to get the props type for SingleSelect and then indexed the type of the opener prop. That way, this component will always match that even if the SingleSelect type gets modified in some future change.

Comment on lines +292 to +311
{
selector:
"JSXElement[openingElement.name.name='UniqueIDProvider']",
message:
"DEPRECATED: Use the `Id` Wonder Blocks Core component instead, or migrate to the `useId` React hook.",
},
{
selector: "JSXElement[openingElement.name.name='IDProvider']",
message:
"DEPRECATED: Use the `Id` Wonder Blocks Core component instead, or migrate to the `useId` React hook.",
},
{
selector: "CallExpression[callee.name='useUniqueIdWithMock']",
message: "DEPRECATED: Use the `useId` React hook instead.",
},
{
selector:
"CallExpression[callee.name='useUniqueIdWithoutMock']",
message: "DEPRECATED: Use the `useId` React hook instead.",
},
Copy link
Member Author

Choose a reason for hiding this comment

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

note: These are to discourage new uses of the deprecated APIs.

somewhatabstract added a commit to Khan/wonder-blocks that referenced this pull request Dec 16, 2024
## Summary:
This is the last piece in the first batch of work. This migrates all Wonder Blocks components off our old ID providers and onto the new `Id` component.

There are also some documentation tweaks to make the deprecation clearer in our stories, since that's some primary documentation for folks.

With this PR, we can cut a release and then begin updating consumer repos accordingly. First, to include this update, then to migrate them off the old ways and onto the new.

### Release process:
Once this small stack of PRs are landed and released, the following PRs need to be updated with that release, then landed/deployed:

- Perseus: Khan/perseus#2007
- Webapp
  - Khan/webapp#28105
  - Khan/webapp#28127


Issue: WB-1812

## Test plan:
`yarn test`
`yarn typecheck`
`yarn start:storybook`

Author: somewhatabstract

Reviewers: jandrade, somewhatabstract

Required Reviewers:

Approved By: jandrade

Checks: ⌛ Lint / Lint (ubuntu-latest, 20.x), ⌛ Check build sizes (ubuntu-latest, 20.x), ⌛ Chromatic - Build on regular PRs / chromatic (ubuntu-latest, 20.x), ⌛ Publish npm snapshot (ubuntu-latest, 20.x), ⌛ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏭️  Chromatic - Skip on Release PR (changesets), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ gerald, ⏭️  dependabot

Pull Request URL: #2391
@somewhatabstract somewhatabstract merged commit ea1bf0c into main Dec 16, 2024
7 of 8 checks passed
@somewhatabstract somewhatabstract deleted the wb1812.1.deprecating branch December 16, 2024 15:52
somewhatabstract added a commit that referenced this pull request Dec 16, 2024
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/[email protected]

### Major Changes

- [#2007](#2007)
[`ea1bf0c2c`](ea1bf0c)
Thanks [@somewhatabstract](https://github.com/somewhatabstract)! -
Update to latest webapp dependencies and prepare for deprecation of
custom WB ID generators

### Patch Changes

- Updated dependencies
\[[`ea1bf0c2c`](ea1bf0c)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Major Changes

- [#2007](#2007)
[`ea1bf0c2c`](ea1bf0c)
Thanks [@somewhatabstract](https://github.com/somewhatabstract)! -
Update to latest webapp dependencies and prepare for deprecation of
custom WB ID generators

### Patch Changes

- Updated dependencies
\[[`ea1bf0c2c`](ea1bf0c)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Major Changes

- [#2007](#2007)
[`ea1bf0c2c`](ea1bf0c)
Thanks [@somewhatabstract](https://github.com/somewhatabstract)! -
Update to latest webapp dependencies and prepare for deprecation of
custom WB ID generators

## @khanacademy/[email protected]

### Major Changes

- [#2007](#2007)
[`ea1bf0c2c`](ea1bf0c)
Thanks [@somewhatabstract](https://github.com/somewhatabstract)! -
Update to latest webapp dependencies and prepare for deprecation of
custom WB ID generators

### Patch Changes

- Updated dependencies
\[[`ea1bf0c2c`](ea1bf0c)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`ea1bf0c2c`](ea1bf0c)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`ea1bf0c2c`](ea1bf0c)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`ea1bf0c2c`](ea1bf0c)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`ea1bf0c2c`](ea1bf0c)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`ea1bf0c2c`](ea1bf0c)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Patch Changes

- Updated dependencies
\[[`ea1bf0c2c`](ea1bf0c)]:
    -   @khanacademy/[email protected]

## @khanacademy/[email protected]

### Major Changes

- [#2007](#2007)
[`ea1bf0c2c`](ea1bf0c)
Thanks [@somewhatabstract](https://github.com/somewhatabstract)! -
Update to latest webapp dependencies and prepare for deprecation of
custom WB ID generators

### Patch Changes

- Updated dependencies
\[[`ea1bf0c2c`](ea1bf0c)]:
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
    -   @khanacademy/[email protected]
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.

4 participants