Skip to content

Commit

Permalink
Use morphing on turbo frame re-rendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
dombesz committed Apr 10, 2024
1 parent 99ccf16 commit 960dc33
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions frontend/package-lock.json

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

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"mime": "^2.5.2",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"morphdom": "^2.7.2",
"mousetrap": "~1.6.3",
"ng-dynamic-component": "^10.7.0",
"ng2-charts": "^4.1.1",
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/turbo/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Turbo from '@hotwired/turbo';
import morphdom from 'morphdom';
import { ModalDialogElement } from '@openproject/primer-view-components/app/components/primer/alpha/modal_dialog';

// Disable default turbo-drive for now as we don't need it for now AND it breaks angular routing
Expand All @@ -24,3 +25,13 @@ document.addEventListener('turbo:submit-end', (event:CustomEvent) => {
dialog && dialog.close(true);
}
});

interface TurboBeforeFrameRenderEventDetail {
render:(currentElement:HTMLElement, newElement:HTMLElement) => void;
}

document.addEventListener('turbo:before-frame-render', (event:CustomEvent<TurboBeforeFrameRenderEventDetail>) => {
event.detail.render = (currentElement:HTMLElement, newElement:HTMLElement) => {
morphdom(currentElement, newElement, { childrenOnly: true });
};
});

0 comments on commit 960dc33

Please sign in to comment.