Skip to content

Commit

Permalink
FIX Prevent nested asset-admin forms from submitting modal
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jan 25, 2024
1 parent f5d54ac commit da9ce9b
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
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 da9ce9b

Please sign in to comment.