From bc49dcd330d95f4cc93e11b1c04871a338cecf7f Mon Sep 17 00:00:00 2001 From: Tim Arney Date: Mon, 24 Jun 2024 12:54:12 -0400 Subject: [PATCH 1/2] fix other when using groups --- .../components/shared/conditionals/AddOther.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/(gcforms)/[locale]/(form administration)/form-builder/components/shared/conditionals/AddOther.tsx b/app/(gcforms)/[locale]/(form administration)/form-builder/components/shared/conditionals/AddOther.tsx index 6e8284014d..60e0657e55 100644 --- a/app/(gcforms)/[locale]/(form administration)/form-builder/components/shared/conditionals/AddOther.tsx +++ b/app/(gcforms)/[locale]/(form administration)/form-builder/components/shared/conditionals/AddOther.tsx @@ -7,6 +7,8 @@ import { FormElementWithIndex } from "@lib/types/form-builder-types"; import { useTemplateStore } from "@lib/store/useTemplateStore"; import { FormElementTypes } from "@lib/types"; import { getTranslatedProperties } from "../../../actions"; +import { useGroupStore } from "@formBuilder/components/shared/right-panel/treeview/store/useGroupStore"; +import { allowGrouping } from "@formBuilder/components/shared/right-panel/treeview/util/allowGrouping"; export const AddOther = ({ item }: { item: FormElementWithIndex }) => { const { t } = useTranslation("form-builder"); @@ -15,6 +17,8 @@ export const AddOther = ({ item }: { item: FormElementWithIndex }) => { add: s.add, })); + const groupId = useGroupStore((state) => state.id); + const addOther = useCallback(async () => { if (!item.properties.choices) return; @@ -41,7 +45,12 @@ export const AddOther = ({ item }: { item: FormElementWithIndex }) => { }, }; - add(item.index, FormElementTypes.textField, data); + const allowGroups = await allowGrouping(); + if (allowGroups) { + add(item.index, FormElementTypes.textField, data, groupId); + } else { + add(item.index, FormElementTypes.textField, data); + } }, [add, item]); return ( From f73651ee64706f832f03aca64832a55df081023c Mon Sep 17 00:00:00 2001 From: Tim Arney Date: Mon, 24 Jun 2024 13:19:58 -0400 Subject: [PATCH 2/2] lint --- .../form-builder/components/shared/conditionals/AddOther.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/(gcforms)/[locale]/(form administration)/form-builder/components/shared/conditionals/AddOther.tsx b/app/(gcforms)/[locale]/(form administration)/form-builder/components/shared/conditionals/AddOther.tsx index 60e0657e55..bdf842df48 100644 --- a/app/(gcforms)/[locale]/(form administration)/form-builder/components/shared/conditionals/AddOther.tsx +++ b/app/(gcforms)/[locale]/(form administration)/form-builder/components/shared/conditionals/AddOther.tsx @@ -51,7 +51,7 @@ export const AddOther = ({ item }: { item: FormElementWithIndex }) => { } else { add(item.index, FormElementTypes.textField, data); } - }, [add, item]); + }, [add, item, groupId]); return (