Skip to content

Commit

Permalink
Changed chained parent calls to .closest as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
droberts-ctrlo committed Oct 11, 2023
1 parent eaf2379 commit e78679b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/frontend/components/button/lib/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,8 @@ class ButtonComponent extends Component {
const $button = $(ev.target).closest('button');
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();

const $parent = $button.closest('.modal-body')

if (!this.requiredHiddenRecordDependentFieldsCleared) {
ev.preventDefault()

Expand Down

0 comments on commit e78679b

Please sign in to comment.