Skip to content

Commit

Permalink
Revert "Optimize events on handler"
Browse files Browse the repository at this point in the history
The targets might not yet be present in the DOM
during initialization. Delegating to the time of
the event fixes issues with the node tree.

This reverts commit 006454a.
  • Loading branch information
tvdeyen committed Dec 5, 2023
1 parent d3590a1 commit 39e98de
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions app/javascript/alchemy_admin/utils/events.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export function on(eventName, baseSelector, targetSelector, callback) {
document.querySelectorAll(baseSelector).forEach((baseNode) => {
const targets = Array.from(baseNode.querySelectorAll(targetSelector))

baseNode.addEventListener(eventName, (evt) => {
const targets = Array.from(baseNode.querySelectorAll(targetSelector))
let currentNode = evt.target

while (currentNode !== baseNode) {
Expand Down

0 comments on commit 39e98de

Please sign in to comment.