Skip to content

Commit 584f7fd

Browse files
authored
(fix) Display only filtered answers for multi-select and content-switcher form components (#695)
* Filter answers to be displayed for multiple form components * Revert the filter in dropdown
1 parent 7583c06 commit 584f7fd

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/components/inputs/content-switcher/content-switcher.component.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,16 @@ const ContentSwitcher: React.FC<FormFieldInputProps> = ({ field, value, errors,
5959
selectedIndex={selectedIndex}
6060
className={styles.selectedOption}
6161
size="md">
62-
{field.questionOptions.answers.map((option, index) => (
63-
<Switch
64-
name={option.concept || option.value}
65-
text={t(option.label)}
66-
key={index}
67-
disabled={field.isDisabled}
68-
/>
69-
))}
62+
{field.questionOptions.answers
63+
.filter((answer) => !answer.isHidden)
64+
.map((option, index) => (
65+
<Switch
66+
name={option.concept || option.value}
67+
text={t(option.label)}
68+
key={index}
69+
disabled={field.isDisabled}
70+
/>
71+
))}
7072
</CdsContentSwitcher>
7173
</FormGroup>
7274
)

src/components/inputs/multi-select/multi-select.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ const MultiSelect: React.FC<FormFieldInputProps> = ({ field, value, errors, warn
110110
/>
111111
) : (
112112
<CheckboxGroup legendText={<FieldLabel field={field} />} readOnly={isTrue(field.readonly)}>
113-
{field.questionOptions.answers?.map((value, index) => {
113+
{selectOptions?.map((value, index) => {
114114
return (
115115
<Checkbox
116116
className={styles.checkbox}
117117
checked={initiallyCheckedQuestionItems.some((item) => item === value.concept)}
118-
disabled={value.disable?.isDisabled}
118+
disabled={value.disabled}
119119
id={`${field.id}-${value.concept}`}
120120
key={`${field.id}-${value.concept}-${index}`}
121121
labelText={t(value.label)}

0 commit comments

Comments
 (0)