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

Modal dismiss on key #242

Merged
merged 8 commits into from
Oct 11, 2023
Merged

Modal dismiss on key #242

merged 8 commits into from
Oct 11, 2023

Conversation

droberts-ctrlo
Copy link
Contributor

This is a horrible fix, but it's the only way I could make it work!

Walks up the tree to see if the button is in a modal, if it is, it calls submit directly, if not, it doesn't.

If you use $button.parents().find('.modal-body') it will find the modal if the button is in a modal, but if it isn't, it enters a loop that crashes the browser while looking for the element.

const $form = $button.closest("form")
const $requiredHiddenRecordDependentFields = $form.find(".form-group[data-has-dependency='1'][style*='display: none'] *[aria-required]")
//This is awful, but if I use a find on all parents to find the .modal-body, the "normal" submit button crashes the browser with an (almost) infinite loop
const $parent = $button.parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().parent();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See if you can get this working with a closest()

@abeverley
Copy link
Contributor

Please also see if you can make this generic to also work on the main record.

Some logging is used within the code for errors etc. - these have been kept
@abeverley abeverley merged commit 833c6fb into ctrlo:uiux Oct 11, 2023
@droberts-ctrlo droberts-ctrlo deleted the modalDismissOnKey branch October 16, 2023 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants