Skip to content

Commit

Permalink
ActiveStorage: Pass useCapture to UJS listener
Browse files Browse the repository at this point in the history
Closes [@hotwired/turborails#243][].

Set the `useCapture` parameter of [addEventListener][] to `true` so that
cancelling the event occurs early enough in the process so that the
resulting upload is cancelled.

[@hotwired/turborails#243]: hotwired/turbo#243 (comment)
[addEventListener]: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#parameters

Co-authored-by: Javan Makhmali <javan@basecamp.com>
  • Loading branch information
seanpdoyle and Javan Makhmali committed Apr 13, 2021
1 parent a613cb5 commit e75b009
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion activestorage/app/assets/javascripts/activestorage.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion activestorage/app/javascript/activestorage/ujs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function start() {
if (!started) {
started = true
document.addEventListener("click", didClick, true)
document.addEventListener("submit", didSubmitForm)
document.addEventListener("submit", didSubmitForm, true)
document.addEventListener("ajax:before", didSubmitRemoteElement)
}
}
Expand Down

0 comments on commit e75b009

Please sign in to comment.