Skip to content

Commit 305a16e

Browse files
committed
Show inline display units
1 parent 84d5e72 commit 305a16e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/app/components/elements/inputs/InlineNumericEntryZone.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import classNames from "classnames";
44
import { Markup } from "../markup";
55
import { IsaacNumericQuestionDTO, QuantityDTO, QuantityValidationResponseDTO } from "../../../../IsaacApiTypes";
66
import { selectors, useAppSelector, useGetConstantUnitsQuery } from "../../../state";
7-
import { isLoggedIn, useCurrentQuestionAttempt } from "../../../services";
7+
import { isDefined, isLoggedIn, useCurrentQuestionAttempt } from "../../../services";
88
import { InlineEntryZoneProps, correctnessClass } from "../markup/portals/InlineEntryZone";
99
import { selectUnits, wrapUnitForSelect } from "../../../services/numericUnits";
1010
import { QuestionCorrectness } from "../../../../IsaacAppTypes";
@@ -46,6 +46,8 @@ export const InlineNumericEntryZone = ({width, height, questionDTO, setModified,
4646
setModified(true);
4747
}
4848

49+
const unit = questionDTO.displayUnit ?? currentAttempt?.units;
50+
4951
return <div {...rest}
5052
className={classNames("inline-numeric-container w-100", rest.className, correctnessClass(valueCorrectness === "NOT_SUBMITTED" ? "NOT_SUBMITTED" : correctness))}
5153
>
@@ -94,7 +96,7 @@ export const InlineNumericEntryZone = ({width, height, questionDTO, setModified,
9496
>
9597
<div className={showFeedback(unitCorrectness) ? "pe-4" : "pe-2"}>
9698
<Markup encoding={"latex"}>
97-
{currentAttempt?.units !== undefined ? wrapUnitForSelect(noDisplayUnit ? currentAttempt.units : questionDTO.displayUnit) : "Unit..."}
99+
{isDefined(unit) ? wrapUnitForSelect(unit) : "Unit..."}
98100
</Markup>
99101
{showFeedback(unitCorrectness) && noDisplayUnit && <div className={"feedback-box ps-2"}>
100102
{unitCorrectness === "NOT_ANSWERED" ?

0 commit comments

Comments
 (0)