Skip to content

Commit

Permalink
Merge pull request #190 from creative-commoners/pulls/4/filelink-submit
Browse files Browse the repository at this point in the history
FIX Prevent nested asset-admin forms from submitting modal
  • Loading branch information
GuySartorelli authored Jan 25, 2024
2 parents f5d54ac + da9ce9b commit 7e077dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions client/src/components/LinkModal/LinkModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ const LinkModal = ({ typeTitle, typeKey, linkID = 0, isOpen, onSuccess, onClosed
*/
const onSubmit = async (modalData, action, submitFn) => {
let formSchema = null;

// Workaround to prevent the FormBuilder form from submitting when any nested FormBuilder forms are present
// This will happen when a FileLink is being used and the "Choose existing" link is clicked which
// will open up an asset-admin modal to select an existing file.
// Clicking any of the following submit buttons will cause LinkModal to inadvertanely submit:
// - "Insert file" which is present when the breakpoint is less than 'lg' (992px)
// - Save/Publish button after clicking on the 'Details' tab of a selected file
if (document.getElementById('Form_fileSelectForm_action_insert')
|| document.getElementById('Form_fileEditForm_Actions_Holder')) {
return Promise.resolve();
}

try {
formSchema = await submitFn();
} catch (error) {
Expand Down

0 comments on commit 7e077dc

Please sign in to comment.