Skip to content

Commit 454cdf7

Browse files
committed
Fix bug where child components would sometimes lose their action events.
1 parent 1f814a4 commit 454cdf7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

django_unicorn/static/js/eventListeners.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ export function addActionEventListener(component, eventType) {
117117
const { action } = actionEvent;
118118
const { element } = actionEvent;
119119

120-
// TOD: Check why the targetElement needs to check isSameNode OR has the same
121-
// key/id since `isSameNode` won't always work
122-
if (targetElement.isSame(element) || targetElement.isSameId(element)) {
120+
if (targetElement.isSame(element)) {
123121
// Add the value of any child element of the target that is a lazy model to the action queue
124122
// Handles situations similar to https://github.com/livewire/livewire/issues/528
125123
component.walker(element.el, (childEl) => {

django_unicorn/static/js/messageSender.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,12 @@ export function send(component, callback) {
141141
MORPHDOM_OPTIONS
142142
);
143143
parentComponent.refreshChecksum();
144+
parentComponent.refreshEventListeners();
144145

145-
// parentComponent.getChildrenComponents().forEach((child) => {
146-
// child.refreshEventListeners();
147-
// });
146+
parentComponent.getChildrenComponents().forEach((child) => {
147+
child.init();
148+
child.refreshEventListeners();
149+
});
148150
}
149151
}
150152

0 commit comments

Comments
 (0)