Skip to content

Commit

Permalink
modified help modal to reset upon closing
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeCodes19 committed Feb 20, 2025
1 parent 56339ad commit f17fc80
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/app/controllers/help_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class HelpController < ApplicationController

def index
@title = t("help.index.title")
render layout: false if turbo_frame_request?
render layout: false
end

def show
Expand Down
21 changes: 21 additions & 0 deletions app/app/javascript/controllers/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,31 @@ export default class extends Controller {
}
}

// Watch for modal visibility changes
this.observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.target.classList.contains('is-hidden')) {
const frame = document.querySelector('#help_modal_content')
if (frame) {
frame.src = '/help'
}
}
})
})

const modalElement = document.getElementById('help-modal')
this.observer.observe(modalElement, {
attributes: true,
attributeFilter: ['class']
})

document.addEventListener("click", this.handleClick)
}

disconnect() {
document.removeEventListener("click", this.handleClick)
if (this.observer) {
this.observer.disconnect()
}
}
}

0 comments on commit f17fc80

Please sign in to comment.