MDL-85007 core: ensure events are dispatched against the same table.

This ensures that we always dispatch the dynamic table updated event
against the same table we just updated. Previously it was possible
for another table to receive the event, where both tables were
effectively the same instance of one another (e.g. custom reports).
This commit is contained in:
Paul Holden
2025-03-25 15:54:21 +00:00
parent b3931cdb95
commit 9263bbf8de
3 changed files with 6 additions and 7 deletions
+2 -2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+3 -4
View File
@@ -26,6 +26,7 @@ import Pending from 'core/pending';
import {addIconToContainer} from 'core/loadingicon';
import {fetch as fetchTableData} from 'core_table/local/dynamic/repository';
import Notification from 'core/notification';
import {replaceNode} from 'core/templates';
let watching = false;
@@ -89,12 +90,10 @@ export const refreshTableContent = (tableRoot, resetContent = false) => {
resetContent,
)
.then(data => {
const placeholder = document.createElement('div');
placeholder.innerHTML = data.html;
tableRoot.replaceWith(...placeholder.childNodes);
const tableRootReplacement = replaceNode(tableRoot, data.html, '');
// Update the tableRoot.
return getTableFromId(tableRoot.dataset.tableUniqueid);
return tableRootReplacement[0];
}).then(tableRoot => {
tableRoot.dispatchEvent(new CustomEvent(Events.tableContentRefreshed, {
bubbles: true,