From cf3407cd0b921780a7030d2f6262f9f4697a1a48 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Fri, 13 Sep 2024 16:50:07 -0400 Subject: [PATCH 1/2] Added DOM_OBJECTS_UPDATED notification each time the DOM is re-rendered. Ensures the module can know when the DOM is available for interaction. Fixes #3534. --- CHANGELOG.md | 1 + js/main.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56db0c20bc..569d7366ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Thanks to: @btoconnor, @bugsounet, @JasonStieber, @khassel, @kleinmantara and @W - [calendar] Added config option "showEndsOnlyWithDuration" for default calendar - [compliments] Added `specialDayUnique` config option, defaults to `false` (#3465) - [weather] Provider weathergov: Use `precipitationLast3Hours` if `precipitationLastHour` is `null` (#3124) +- [core] Added `DOM_OBJECTS_UPDATED` notification each time the DOM is re-rendered via `updateDom` (#3534) ### Removed diff --git a/js/main.js b/js/main.js index e50a67f0fc..84fd1105dd 100644 --- a/js/main.js +++ b/js/main.js @@ -666,7 +666,12 @@ const MM = (function () { } // Further implementation is done in the private method. - updateDom(module, updateOptions); + let update_promise = updateDom(module, updateOptions); + + // Once the update is complete and rendered, send a notification to the module that the DOM has been updated + update_promise.then(function () { + sendNotification("DOM_OBJECTS_UPDATED", null, null, module); + }); }, /** From 8213c23eb973c2e235c83e686e4decaa275a0bd4 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Sun, 15 Sep 2024 16:36:43 -0400 Subject: [PATCH 2/2] Added then call to end of function call for explicit async notification update --- js/main.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/js/main.js b/js/main.js index 84fd1105dd..6ff67b93e8 100644 --- a/js/main.js +++ b/js/main.js @@ -666,10 +666,8 @@ const MM = (function () { } // Further implementation is done in the private method. - let update_promise = updateDom(module, updateOptions); - - // Once the update is complete and rendered, send a notification to the module that the DOM has been updated - update_promise.then(function () { + updateDom(module, updateOptions).then(function () { + // Once the update is complete and rendered, send a notification to the module that the DOM has been updated sendNotification("DOM_OBJECTS_UPDATED", null, null, module); }); },