From e78679b8bf560684be047a3781be60b45e29137c Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Wed, 11 Oct 2023 16:39:01 +0100 Subject: [PATCH] Changed chained parent calls to .closest as suggested --- src/frontend/components/button/lib/component.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/frontend/components/button/lib/component.js b/src/frontend/components/button/lib/component.js index 3cb35798c..b677c9a93 100644 --- a/src/frontend/components/button/lib/component.js +++ b/src/frontend/components/button/lib/component.js @@ -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()