Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/poor-buckets-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Fix height difference when displaying NOTA (none of the above) radio choice
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,19 @@ describe("Multiple choice component", () => {
expect(screen.getByText("foo-bar-zot")).toBeInTheDocument();
});

it("uses the i18n version of 'None of the above' when the choice is set as such", () => {
it("displays provided content for 'None of the above' choices", () => {
// The widget layer is responsible for setting the correct content
// for NOTA choices. The component just displays whatever content
// is passed to it.
Copy link
Contributor

Choose a reason for hiding this comment

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

If that is the case, then this test is not needed since there is no logic to test.

const choiceOverrides = {
isNoneOfTheAbove: true,
content: "foo-bar-zot",
content: "Custom NOTA content",
};
const props = getComponentProps({
choiceOverrides,
});
render(<MultipleChoiceComponent {...props} />);
expect(screen.queryByText("foo-bar-zot")).not.toBeInTheDocument();
expect(screen.getByText("None of the above")).toBeInTheDocument();
expect(screen.getByText("Custom NOTA content")).toBeInTheDocument();
});

it("shows the provided rationale when in review mode", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ const ChoiceListItems = (props: ChoiceListItemsProps): React.ReactElement => {
? "correct"
: "wrong"
: undefined;
const content = choice.isNoneOfTheAbove
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the redundant NOTA content override that was replacing Renderer-wrapped content with a plain string

Copy link
Contributor

Choose a reason for hiding this comment

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

If this change is kept, then there needs to be a way to ensure that this string is included in the choice content. The current usage of the NOTA in the editor is that the text is not editable. If I recall correctly, the content for a NOTA choice is an empty string.

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently, this code is ensuring that the NOTA option has been translated in a consistent manner. If this text is managed elsewhere, then it will need to ensure the same results.

? i18nStrings.noneOfTheAbove
: choice.content;
let rationale: React.ReactElement | undefined;
if (reviewMode && choice.hasRationale) {
const rationaleId = `${contentId}-rationale`;
Expand All @@ -219,7 +216,7 @@ const ChoiceListItems = (props: ChoiceListItemsProps): React.ReactElement => {
updateChecked={updateChecked}
>
<div className={styles.content}>
<div id={contentId}>{content}</div>
<div id={contentId}>{choice.content}</div>
{rationale}
</div>
</Choice>
Expand Down
Loading