Skip to content

Commit

Permalink
Prevent duplication of actions within appendAction Stimulus method
Browse files Browse the repository at this point in the history
  • Loading branch information
spohlenz committed Dec 4, 2024
1 parent f324bb5 commit 98db106
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/assets/bundle/trestle/admin.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion frontend/js/controllers/application_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { fetchWithErrorHandling, fetchTurboStream } from '../core/fetch'
export default class extends Controller {
appendAction (event, method, element = this.element) {
const actions = this.actionsList
actions.push(`${event}->${this.identifier}#${method}`)
const newAction = `${event}->${this.identifier}#${method}`

if (!actions.includes(newAction)) {
actions.push(newAction)
}

element.dataset.action = actions.join(' ')
}
Expand Down

0 comments on commit 98db106

Please sign in to comment.