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 Prevent nested asset-admin forms from submitting modal #190

Merged
Merged
Show file tree
Hide file tree
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
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
Loading