Skip to content

Commit

Permalink
Fix bug where child components would sometimes lose their action events.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamghill committed Jan 24, 2021
1 parent 1f814a4 commit 454cdf7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions django_unicorn/static/js/eventListeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ export function addActionEventListener(component, eventType) {
const { action } = actionEvent;
const { element } = actionEvent;

// TOD: Check why the targetElement needs to check isSameNode OR has the same
// key/id since `isSameNode` won't always work
if (targetElement.isSame(element) || targetElement.isSameId(element)) {
if (targetElement.isSame(element)) {
// Add the value of any child element of the target that is a lazy model to the action queue
// Handles situations similar to https://github.com/livewire/livewire/issues/528
component.walker(element.el, (childEl) => {
Expand Down
8 changes: 5 additions & 3 deletions django_unicorn/static/js/messageSender.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,12 @@ export function send(component, callback) {
MORPHDOM_OPTIONS
);
parentComponent.refreshChecksum();
parentComponent.refreshEventListeners();

// parentComponent.getChildrenComponents().forEach((child) => {
// child.refreshEventListeners();
// });
parentComponent.getChildrenComponents().forEach((child) => {
child.init();
child.refreshEventListeners();
});
}
}

Expand Down

0 comments on commit 454cdf7

Please sign in to comment.