Skip to content

Commit 05a1036

Browse files
authored
fix: uncontrolled linear scale not updating (#1272)
* fix: Uncontrolled linear scale question not updating when going back * chore: Release 12.0.3
1 parent f6c8839 commit 05a1036

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@equinor/amplify-component-lib",
3-
"version": "12.0.2",
3+
"version": "12.0.3",
44
"description": "Frontend Typescript components for the Amplify team",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/providers/SurveyProvider/SurveyDialog/SurveyQuestion/SurveyLinearScaleQuestion.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export const SurveyLinearScaleQuestion: FC<SurveyLinearScaleQuestionProps> = ({
4343
}) => {
4444
const { currentAnswer, setCurrentAnswer } = useSurvey();
4545
const rangeAmount = linearScaleVm.maxValue - linearScaleVm.minValue + 1;
46+
const currentNumericAnswer = (
47+
'setAnswer' in rest ? rest.answer : currentAnswer
48+
)?.numericAnswer;
4649

4750
const handleOnAnswer = (numericAnswer: number) => {
4851
if ('answer' in rest && 'setAnswer' in rest) {
@@ -70,12 +73,9 @@ export const SurveyLinearScaleQuestion: FC<SurveyLinearScaleQuestionProps> = ({
7073
data-testid={`range-radio-${questionId.value}`}
7174
name={`range-${questionId.value}`}
7275
label=""
73-
checked={
74-
('answer' in rest ? rest.answer : currentAnswer)
75-
?.numericAnswer ===
76-
index + linearScaleVm.minValue
77-
}
78-
onClick={() => {
76+
value={linearScaleVm.minValue + index}
77+
checked={currentNumericAnswer === linearScaleVm.minValue + index}
78+
onChange={() => {
7979
handleOnAnswer(linearScaleVm.minValue + index);
8080
}}
8181
/>

0 commit comments

Comments
 (0)