Skip to content

Commit 7fa932f

Browse files
Merge 24.3 to 24.7
2 parents c4cbee2 + 8c834b7 commit 7fa932f

File tree

1 file changed

+13
-39
lines changed

1 file changed

+13
-39
lines changed

LDK/resources/web/LDK/panel/ContentResizingPanel.js

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
22
* This is designed to help with the problem of rendering dynamic content into Ext4 panels. It's a little ugly, but this
3-
* component provides a div into which you render the webpart or report. On load, it will listen for that element's DOMSubtreeModified/DOMNodeInserted
4-
* event, and resize the Ext containers if needed. It attempts to batch these events and only actually trigger a layout when a resize
5-
* is needed.
3+
* component provides a div into which you render the webpart or report. On load, it will use a mutation observer to listen for
4+
* events that indicate content has been inserted. When that happens, it will fire a 'contentsizechange' event and resize
5+
* the Ext containers if needed. It attempts to batch these events and only actually trigger a layout when a resize is needed.
66
*
7-
* NOTE: this currently handles the problem by adding DOMSubtreeModified/DOMNodeInserted listeners and manually resizing on change.
7+
* NOTE: this currently handles the problem by adding a mutation observer and manually resizing on change.
88
* A more elegant solution would be to dig into Ext's layout engine and make a custom layout that will
99
* auto-size itself based on the width of our target element. We'd need to override the methods that calculate weight and height.
1010
* Figuring that out will make WebPartPanel work better too.
@@ -40,41 +40,15 @@ Ext4.define('LDK.mixin.ContentResizing', {
4040
return;
4141
}
4242

43-
if (Ext4.isIE){
44-
var cmp = this;
45-
46-
el = el.query('*[name="webpart"]')[0];
47-
if (!Ext4.isDefined(el) && !isRetry){
48-
Ext4.defer(this.createListeners, 250, this, [true]);
49-
return;
50-
}
51-
52-
if (!el && isRetry) {
53-
return;
54-
}
55-
56-
if (el.addEventListener){
57-
el.addEventListener('DOMSubtreeModified', function(){
58-
cmp.fireEvent('contentsizechange');
59-
}, false);
60-
}
61-
else if (el.attachEvent){
62-
el.attachEvent('DOMSubtreeModified', function(){
63-
cmp.fireEvent('contentsizechange');
64-
});
65-
}
66-
else {
67-
LDK.Utils.logToServer({
68-
message: 'Unable to find appropriate event in ContentResizingPanel',
69-
level: 'ERROR',
70-
includeContext: true
71-
});
72-
}
73-
}
74-
else if (Ext4.isDefined(el)) {
75-
el.on('DOMNodeInserted', function(){
76-
this.fireEvent('contentsizechange');
77-
}, this);
43+
if (Ext4.isDefined(el)) {
44+
// Issue 50942: Removal of support for mutation events. This replaces DOMNodeInserted event handler.
45+
const observer = new MutationObserver(mutationList =>
46+
mutationList.filter(m => m.type === 'childList').forEach(m => {
47+
m.addedNodes.forEach(function(){
48+
this.fireEvent('contentsizechange');
49+
}, this);
50+
}));
51+
observer.observe(el.dom,{childList: true, subtree: true});
7852

7953
// Issue 31454: if the output has a clickable labkey-wp-header, also listen for that event
8054
Ext4.each(el.query('.labkey-wp-header'), function(wpHeader) {

0 commit comments

Comments
 (0)