diff --git a/.changeset/many-boxes-wave.md b/.changeset/many-boxes-wave.md deleted file mode 100644 index 71f9396122..0000000000 --- a/.changeset/many-boxes-wave.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@khanacademy/perseus-editor": minor ---- - -Addition of a new alert for the content editors when Input numbers are converted to Numeric Inputs diff --git a/.changeset/moody-dingos-relate.md b/.changeset/moody-dingos-relate.md new file mode 100644 index 0000000000..6471e69f85 --- /dev/null +++ b/.changeset/moody-dingos-relate.md @@ -0,0 +1,6 @@ +--- +"@khanacademy/perseus": patch +"@khanacademy/perseus-editor": patch +--- + +Fixing a regression and a bug in the Input Conversion Logic diff --git a/.changeset/quick-mangos-end.md b/.changeset/quick-mangos-end.md new file mode 100644 index 0000000000..d1a229b9b7 --- /dev/null +++ b/.changeset/quick-mangos-end.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus-editor": patch +--- + +Fixing a regression in the Input Conversion Logic diff --git a/packages/perseus-editor/src/article-editor.tsx b/packages/perseus-editor/src/article-editor.tsx index aa47755ae6..c7b6841a3e 100644 --- a/packages/perseus-editor/src/article-editor.tsx +++ b/packages/perseus-editor/src/article-editor.tsx @@ -74,9 +74,7 @@ export default class ArticleEditor extends React.Component { // Check if the json needs to be converted const conversionWarningRequired = props.json instanceof Array - ? props.json - .map(conversionRequired) - .reduce((p, v) => p && v, false) + ? props.json.some(conversionRequired) : conversionRequired(props.json); let json = props.json; diff --git a/packages/perseus-editor/src/util/deprecated-widgets/input-number.ts b/packages/perseus-editor/src/util/deprecated-widgets/input-number.ts index 5c5cc45182..a753b51966 100644 --- a/packages/perseus-editor/src/util/deprecated-widgets/input-number.ts +++ b/packages/perseus-editor/src/util/deprecated-widgets/input-number.ts @@ -52,8 +52,11 @@ export const convertInputNumberWidgetOptions = ( } // Check if the widget is an input-number if (widgets[key].type === "input-number") { + // If the answerType is not number or percent, we need to provide + // the answer form for the numeric-input widget const provideAnswerForm = - widgets[key].options.answerType !== "number"; + widgets[key].options.answerType !== "number" && + widgets[key].options.answerType !== "percent"; // We need to determine the mathFormat for the numeric-input widget const mathFormat = widgets[key].options.answerType === "rational" diff --git a/packages/perseus/src/widgets/numeric-input/numeric-input.tsx b/packages/perseus/src/widgets/numeric-input/numeric-input.tsx index a162b2e564..192fa84a36 100644 --- a/packages/perseus/src/widgets/numeric-input/numeric-input.tsx +++ b/packages/perseus/src/widgets/numeric-input/numeric-input.tsx @@ -349,7 +349,11 @@ const propUpgrades = { // input-number to numeric-input. In this case, we need to upgrade // the widget options accordingly. if (initialProps.value) { - const provideAnswerForm = initialProps.answerType !== "number"; + // If the answerType is not number or percent, we need to provide + // the answer form for the numeric-input widget + const provideAnswerForm = + initialProps.answerType !== "number" && + initialProps.answerType !== "percent"; // We need to determine the mathFormat for the numeric-input widget const mathFormat =