diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php index 02283a1a6..f8b0c4a26 100644 --- a/resources/views/components/modal-confirmation.blade.php +++ b/resources/views/components/modal-confirmation.blade.php @@ -40,32 +40,34 @@ this.deleteText = ''; this.password = ''; this.userConfirmText = ''; - this.passwordError = ''; this.selectedActions = @js(collect($checkboxes)->pluck('id')->all()); + $wire.$refresh(); }, step1ButtonText: @js($step1ButtonText), step2ButtonText: @js($step2ButtonText), step3ButtonText: @js($step3ButtonText), validatePassword() { - this.passwordError = ''; if (this.confirmWithPassword && !this.password) { - this.passwordError = 'Password is required.'; - return false; + return 'Password is required.'; } - return true; + return ''; }, submitForm() { - if (this.validatePassword()) { - $wire.call(this.submitAction, this.password, this.selectedActions) - .then(result => { - if (result === true) { - this.modalOpen = false; - this.resetModal(); - } else if (typeof result === 'string') { - this.passwordError = result; - } - }); + if (this.confirmWithPassword) { + this.passwordError = this.validatePassword(); + if (this.passwordError) { + return; + } } + $wire.call(this.submitAction, this.password, this.selectedActions) + .then(result => { + if (result === true) { + this.modalOpen = false; + this.resetModal(); + } else if (typeof result === 'string') { + this.passwordError = result; + } + }); }, copyConfirmText() { navigator.clipboard.writeText(this.confirmText); @@ -82,7 +84,7 @@ this.selectedActions.push(id); } } -}" @keydown.escape.window="modalOpen = false; resetModal()" :class="{ 'z-40': modalOpen }" class="relative w-auto h-auto" @password-error.window="passwordError = $event.detail"> +}" @keydown.escape.window="modalOpen = false; resetModal()" :class="{ 'z-40': modalOpen }" class="relative w-auto h-auto"> @if ($customButton) @if ($buttonFullWidth) @@ -134,7 +136,7 @@ @endif -