Skip to content

Commit c4cb27b

Browse files
committed
MC-4014: PageBuilder Performance Is Bad With Minimal Content
- Inform the domObserver to ignore the Page Builder canvas node and child nodes
1 parent 954b7d4 commit c4cb27b

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/stage.js

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/stage.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ko from "knockout";
77
import $t from "mage/translate";
88
import events from "Magento_PageBuilder/js/events";
99
import "Magento_PageBuilder/js/resource/jquery/ui/jquery.ui.touch-punch.min";
10+
import domObserver from "Magento_Ui/js/lib/view/utils/dom-observer";
1011
import alertDialog from "Magento_Ui/js/modal/alert";
1112
import _ from "underscore";
1213
import "./binding/sortable";
@@ -85,7 +86,10 @@ export default class Stage {
8586
/**
8687
* The stage has been initiated fully and is ready
8788
*/
88-
public ready() {
89+
public ready([buildResults, canvasElement]: [any[], HTMLElement]) {
90+
// Disable the dom observer from running on our canvas
91+
domObserver.disableNode(canvasElement);
92+
8993
events.trigger(`stage:${ this.id }:readyAfter`, {stage: this});
9094
this.loading(false);
9195
this.initListeners();
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
export interface DomObserver {
7+
/**
8+
* Disable a node from being observed by the mutations
9+
*
10+
* @param {HTMLElement} node
11+
*/
12+
disableNode(node: HTMLElement): void;
13+
14+
/**
15+
* Adds listener for the appearance of nodes that matches provided
16+
* selector and which are inside of the provided context. Callback will be
17+
* also invoked on elements which a currently present.
18+
*
19+
* @param {String} selector - CSS selector.
20+
* @param {Function} callback - Function that will invoked when node appears.
21+
* @param {HTMLElement} [ctx=document.body] - Context inside of which to search for the node.
22+
*/
23+
get(selector: string, callback: () => void, ctx: HTMLElement): void;
24+
25+
/**
26+
* Adds listener for the nodes removal.
27+
*
28+
* @param {(jQueryObject|HTMLElement|Array|String)} selector
29+
* @param {Function} callback - Function that will invoked when node is removed.
30+
* @param {HTMLElement} [ctx=document.body] - Context inside of which to search for the node.
31+
*/
32+
remove(selector: string, callback: () => void, ctx: HTMLElement): void;
33+
34+
/**
35+
* Removes listeners.
36+
*
37+
* @param {String} selector
38+
* @param {Function} [fn]
39+
*/
40+
off(selector: string, fn: () => void): void;
41+
}
42+
43+
declare module "Magento_Ui/js/lib/view/utils/dom-observer" {
44+
export = DomObserver;
45+
}

0 commit comments

Comments
 (0)