Skip to content

Commit

Permalink
(feat) O3-3481 Adds option to display multicheckbox inline
Browse files Browse the repository at this point in the history
  • Loading branch information
pirupius committed Jun 26, 2024
1 parent c7620fe commit f5f59c8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/components/inputs/multi-select/multi-select.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,7 @@ const MultiSelect: React.FC<FormFieldProps> = ({ question, onChange, handler, pr
<>
<div className={styles.boldedLabel}>
<Layer>
{question.questionOptions.answers?.length > 5 ? (
<FilterableMultiSelect
placeholder={t('search', 'Search') + '...'}
onChange={handleSelectItemsChange}
id={t(question.label)}
items={selectOptions}
initialSelectedItems={initiallySelectedQuestionItems}
label={''}
titleText={label}
key={counter}
itemToString={(item) => (item ? item.label : ' ')}
disabled={question.isDisabled}
invalid={errors.length > 0}
invalidText={errors[0]?.message}
warn={warnings.length > 0}
warnText={warnings[0]?.message}
readOnly={question.readonly}
/>
) : (
{question.inlineMultiCheckbox ? (
<CheckboxGroup legendText={label} name={question.id}>
{question.questionOptions.answers?.map((value, index) => {
return (
Expand All @@ -146,6 +128,24 @@ const MultiSelect: React.FC<FormFieldProps> = ({ question, onChange, handler, pr
);
})}
</CheckboxGroup>
) : (
<FilterableMultiSelect
placeholder={t('search', 'Search') + '...'}
onChange={handleSelectItemsChange}
id={t(question.label)}
items={selectOptions}
initialSelectedItems={initiallySelectedQuestionItems}
label={''}
titleText={label}
key={counter}
itemToString={(item) => (item ? item.label : ' ')}
disabled={question.isDisabled}
invalid={errors.length > 0}
invalidText={errors[0]?.message}
warn={warnings.length > 0}
warnText={warnings[0]?.message}
readOnly={question.readonly}
/>
)}
</Layer>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export interface FormField {
questionInfo?: string;
historicalExpression?: string;
constrainMaxWidth?: boolean;
inlineMultiCheckbox?: boolean;
meta?: QuestionMetaProps;
}

Expand Down

0 comments on commit f5f59c8

Please sign in to comment.