Skip to content

Commit

Permalink
fix: sub element modal (#4347)
Browse files Browse the repository at this point in the history
fix sub element modal
  • Loading branch information
timarney authored Oct 1, 2024
1 parent 53e258d commit 5894b7f
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ export const SubElementModal = ({
const { t } = useTranslation("form-builder");
const { modals, updateModalProperties, unsetModalField } = useModalStore();

const { updateField } = useTemplateStore((s) => ({
const { updateField, setChangeKey } = useTemplateStore((s) => ({
updateField: s.updateField,
setChangeKey: s.setChangeKey,
}));

const forceRefresh = () => {
setChangeKey(String(new Date().getTime())); //Force a re-render
};

useEffect(() => {
if (item.type != "richText") {
updateModalProperties(item.index, item.properties);
Expand All @@ -45,11 +50,14 @@ export const SubElementModal = ({
}) => {
return (e: React.MouseEvent<HTMLElement>) => {
e.preventDefault();

// replace all of "properties" with the new properties set in the ModalForm
updateField(
`form.elements[${elIndex}].properties.subElements[${subIndex}].properties`,
properties
);

forceRefresh();
};
};

Expand Down

0 comments on commit 5894b7f

Please sign in to comment.