Skip to content

Commit

Permalink
bug/673-modal-not-closing (#686)
Browse files Browse the repository at this point in the history
* remove fade class to prevent wrong animation

* implement custom fade animation
  • Loading branch information
Vakmeth authored May 3, 2024
1 parent 690bd8c commit 6452afe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
11 changes: 10 additions & 1 deletion app/assets/stylesheets/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,13 @@ pzsh-topbar {

.modal-title {
word-break: break-word;
}
}

#modal-animation {
opacity: 0;
transition: opacity 0.5s;
}

#modal-animation.fader {
opacity: 1;
}
10 changes: 8 additions & 2 deletions app/javascript/controllers/remote_modal_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ import { Modal } from "bootstrap"

export default class extends Controller {
connect() {
this.modal = new Modal(this.element)
this.modal.show()
this.modal = new Modal(this.element);
this.modal.show();
this.element.classList.toggle('fader');
}

disconnect() {
this.element.classList.remove('fader');
}


hideBeforeRender(event) {
if (this.isOpen()) {
event.preventDefault()
Expand Down
3 changes: 2 additions & 1 deletion app/views/application/_remote_modal.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
= turbo_frame_tag "remote_modal" do
.modal.fade{tabindex:"-1", "data-controller":"remote-modal", "data-action":"turbo:before-render@document->remote-modal#hideBeforeRender"}
#modal-animation.modal{tabindex:"-1", "data-controller":"remote-modal",
"data-action":"turbo:before-render@document->remote-modal#hideBeforeRender"}
.modal-dialog
.modal-content
.modal-header
Expand Down

0 comments on commit 6452afe

Please sign in to comment.