Skip to content

Commit

Permalink
fix: "Other" question field isn't showing up, so clicking the link "O…
Browse files Browse the repository at this point in the history
…ther" takes you no where (#3887)

* fix other when using groups
  • Loading branch information
timarney authored Jun 24, 2024
1 parent ed4c282 commit 4ed450d
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;

Expand All @@ -41,8 +45,13 @@ export const AddOther = ({ item }: { item: FormElementWithIndex }) => {
},
};

add(item.index, FormElementTypes.textField, data);
}, [add, item]);
const allowGroups = await allowGrouping();
if (allowGroups) {
add(item.index, FormElementTypes.textField, data, groupId);
} else {
add(item.index, FormElementTypes.textField, data);
}
}, [add, item, groupId]);

return (
<Button className="!m-0 !mt-4" theme="link" onClick={addOther}>
Expand Down

0 comments on commit 4ed450d

Please sign in to comment.