Skip to content

Commit

Permalink
better typesafety
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHabenicht committed Apr 11, 2021
1 parent 02c5eec commit 0606042
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ export function QuestionnaireFormEditor(props: QuestionnaireFormEditorProps) {
}
};

const handleAddItem = (section: SectionTypeArray) => {
const handleAddItem = (section: SectionTypeArray, template: boolean = false) => {
dispatch(
addNewItem({
section: section,
template: section === undefined ? questionnaireInEditor.questionnaire[section]![activeItem.index] : undefined,
template: template ? questionnaireInEditor.questionnaire[section]?.[activeItem.index] : undefined,
})
);
handleActiveItemChange(activeItem.section, questionnaireInEditor.questionnaire[section]?.length || 0);
Expand Down Expand Up @@ -373,7 +373,7 @@ export function QuestionnaireFormEditor(props: QuestionnaireFormEditorProps) {
<IconButton
aria-label="copy"
onClick={() => {
if (!isNonArraySection(activeItem.section)) handleAddItem(activeItem.section);
if (!isNonArraySection(activeItem.section)) handleAddItem(activeItem.section, true);
}}
>
<FileCopy />
Expand Down

0 comments on commit 0606042

Please sign in to comment.