Skip to content

Commit 618b171

Browse files
Merge pull request #142 from indec-it/feat/beAbleToHideQuestion
feat(question): be able to hide question
2 parents df206e2 + a247012 commit 618b171

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@indec/form-builder",
3-
"version": "5.0.5",
3+
"version": "5.1.0",
44
"description": "Form builder",
55
"main": "index.js",
66
"private": false,

src/components/QuestionBuilder/Question/Question.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,21 @@ function Question({sectionIndex, questionIndex, disabled = false, warnings = {},
3333
}
3434

3535
useEffect(() => {
36-
if (shouldClean && !question.readOnly && !isInHeader) {
36+
if (shouldClean && !question.readOnly && !isInHeader && !question.hide) {
3737
const defaultAnswerValue = buildQuestions(section)[section.name][0][question.name].answer;
3838
setFieldValue(questionName, defaultAnswerValue);
3939
shouldClean = false;
4040
}
4141
}, [shouldClean, questionName, isInHeader]);
4242

4343
const Component = getQuestionComponent(questionType);
44-
return Component ? (
45-
<Wrapper component={Component} section={section} {...props} />
46-
) : (
47-
<p className="fb:text-red-600 fb:font-medium">Invalid component.</p>
48-
);
44+
if (Component && !question.hide) {
45+
return <Wrapper component={Component} section={section} {...props} />;
46+
}
47+
if (!Component) {
48+
return <p className="fb:text-red-600 fb:font-medium">Invalid component.</p>;
49+
}
50+
return null;
4951
}
5052

5153
export default Question;

0 commit comments

Comments
 (0)