Skip to content

Commit

Permalink
Removing all instances of useV2Keypad (#794)
Browse files Browse the repository at this point in the history
## Summary:
Now that we've fully moved towards our v2keypad everywhere in webapp, we can remove the useV2Keypad from the keypad apiOptions. I also removed some errant keypad types that are no longer used: MATH_INPUT_KEYPAD_V1 and PERSEUS_MATH_INPUT. We'll also be able to clean this code up even further with [this future ticket](https://khanacademy.atlassian.net/browse/LC-1318). 

Issue: LC-1088

## Test plan:
manual+automatic testing

Author: SonicScrewdriver

Reviewers: jeremywiebe, handeyeco, nedredmond

Required Reviewers:

Approved By: jeremywiebe

Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage, ✅ Publish npm snapshot (ubuntu-latest, 16.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 16.x), ✅ Extract i18n strings (ubuntu-latest, 16.x), ✅ Cypress (ubuntu-latest, 16.x), ✅ Jest Coverage (ubuntu-latest, 16.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 16.x), ✅ Check builds for changes in size (ubuntu-latest, 16.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 16.x), ✅ gerald

Pull Request URL: #794
  • Loading branch information
SonicScrewdriver authored Dec 4, 2023
1 parent 3cf5ac4 commit a91c84f
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 35 deletions.
7 changes: 7 additions & 0 deletions .changeset/grumpy-humans-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@khanacademy/math-input": minor
"@khanacademy/perseus": minor
"@khanacademy/perseus-core": minor
---

Removing the useV2Keypad apiOption as the V1 keypad is no longer in use.
2 changes: 0 additions & 2 deletions packages/perseus-core/src/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export type VirtualKeypadVersion =
| "PERSEUS_MATH_INPUT"
| "MATH_INPUT_KEYPAD_V1"
| "MATH_INPUT_KEYPAD_V2"
| "REACT_NATIVE_KEYPAD";

Expand Down
6 changes: 0 additions & 6 deletions packages/perseus/src/perseus-api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ export const ApiOptions = {
// Indicates whether or not to use mobile styling.
isMobile: PropTypes.bool,

// Whether to use v1 (Legacy) Keypad for MathInput mobile or
// use the new v2 Keypad
// TODO [LC-1088]: remove after v2 release
useV2Keypad: PropTypes.bool,

// A function, called with a bool indicating whether use of the
// drawing area (scratchpad) should be allowed/disallowed.
// Previously handled by `Khan.scratchpad.enable/disable`
Expand Down Expand Up @@ -150,7 +145,6 @@ export const ApiOptions = {
defaults: {
isArticle: false,
isMobile: false,
useV2Keypad: false,
onInputError: function () {},
onFocusChange: function () {},
GroupMetadataEditor: StubTagEditor,
Expand Down
5 changes: 0 additions & 5 deletions packages/perseus/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ export type APIOptions = Readonly<{
// from the math-input repo instead of the existing perseus math
// input components.
customKeypad?: boolean;
// Whether to use v1 (Legacy) Keypad for MathInput mobile or
// use the new v2 Keypad
// TODO [LC-1088]: remove after v2 release
useV2Keypad?: boolean;
// If this is provided, it is called instead of appending an instance
// of `math-input`'s keypad to the body. This is used by the native
// apps so they can have the keypad be defined on the native side.
Expand Down Expand Up @@ -362,7 +358,6 @@ export type APIOptionsWithDefaults = Readonly<
inModal: NonNullable<APIOptions["inModal"]>;
isArticle: NonNullable<APIOptions["isArticle"]>;
isMobile: NonNullable<APIOptions["isMobile"]>;
useV2Keypad: NonNullable<APIOptions["useV2Keypad"]>;
onFocusChange: NonNullable<APIOptions["onFocusChange"]>;
onInputError: NonNullable<APIOptions["onInputError"]>;
readOnly: NonNullable<APIOptions["readOnly"]>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const WrappedKeypadContext = ({
apiOptions={{
isMobile: isMobile,
customKeypad: customKeypad,
useV2Keypad: true,
}}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ function RendererWithContext({item}) {
apiOptions={{
isMobile: true,
customKeypad: true,
useV2Keypad: true,
}}
item={item}
problemNum={0}
Expand Down
19 changes: 4 additions & 15 deletions packages/perseus/src/widgets/__tests__/expression.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const assertCorrect = (itemData: PerseusItem, input: string) => {
type: "perseus:expression-evaluated",
payload: {
result: "correct",
virtualKeypadVersion: "PERSEUS_MATH_INPUT",
virtualKeypadVersion: "MATH_INPUT_KEYPAD_V2",
},
});
};
Expand All @@ -54,7 +54,7 @@ const assertIncorrect = (itemData: PerseusItem, input: string) => {
type: "perseus:expression-evaluated",
payload: {
result: "incorrect",
virtualKeypadVersion: "PERSEUS_MATH_INPUT",
virtualKeypadVersion: "MATH_INPUT_KEYPAD_V2",
},
});
};
Expand Down Expand Up @@ -224,19 +224,8 @@ describe("Expression Widget", function () {
);
});

it("should set the virtual keypad version to MATH_INPUT_KEYPAD_V1 when customKeypad is set and useV2Keypad is unset", () => {
assertKeypadVersion({customKeypad: true}, "MATH_INPUT_KEYPAD_V1");
});

it("should set the virtual keypad version to MATH_INPUT_KEYPAD_V2 when customKeypad is set and useV2Keypad is true", () => {
assertKeypadVersion(
{customKeypad: true, useV2Keypad: true},
"MATH_INPUT_KEYPAD_V2",
);
});

it("should default the virtual keypad version to PERSEUS_MATH_INPUT", () => {
assertKeypadVersion(Object.freeze({}), "PERSEUS_MATH_INPUT");
it("should default the virtual keypad version to MATH_INPUT_KEYPAD_V2", () => {
assertKeypadVersion(Object.freeze({}), "MATH_INPUT_KEYPAD_V2");
});
});
});
Expand Down
6 changes: 1 addition & 5 deletions packages/perseus/src/widgets/expression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ const deriveKeypadVersion = (apiOptions: APIOptions) => {
// can remove this `virtualKeypadVersion` field entirely.
return apiOptions.nativeKeypadProxy != null
? "REACT_NATIVE_KEYPAD"
: apiOptions.customKeypad === true
? apiOptions.useV2Keypad === true
? "MATH_INPUT_KEYPAD_V2"
: "MATH_INPUT_KEYPAD_V1"
: "PERSEUS_MATH_INPUT";
: "MATH_INPUT_KEYPAD_V2";
};

type Rubric = PerseusExpressionWidgetOptions;
Expand Down

0 comments on commit a91c84f

Please sign in to comment.