Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: "Other" question field isn't showing up, so clicking the link "Other" takes you no where #3887

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading