Skip to content

Commit 83f28ef

Browse files
author
rmmayo
committed
#3199 - do not cache invalid answers
1 parent f670219 commit 83f28ef

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

dashboard/src/common-components/utilities/UseCheckIfAnswerChangedForValidation.js

+8
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,16 @@ export const useCheckIfAnswerChangedForValidation = () => {
3030
const reset = () => {
3131
cache.clear()
3232
}
33+
const removeAnswer = (testContext) => {
34+
const quizAnswers = testContext?.parent.quizAnswers
35+
if (quizAnswers && quizAnswers.length === 1 && quizAnswers[0].id) {
36+
const answerId = quizAnswers[0].id
37+
cache.delete(context)
38+
}
39+
}
3340
return {
3441
hasValueChanged,
42+
removeAnswer,
3543
reset
3644
}
3745
}

dashboard/src/validators/UseCustomGlobalValidators.js

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const useCustomGlobalValidators = () => {
5757
if (result.valid) {
5858
return true
5959
}
60+
checkIfAnswerChangedForValidation.removeAnswer(context)
6061
let fieldNameToUse = fieldName ? fieldName : '';
6162
if (!fieldNameToUse && fieldNameFunction) {
6263
fieldNameToUse = fieldNameFunction(context);

0 commit comments

Comments
 (0)