Fixed JS error when viewing soft deleted thread

DragonByte Tech

Well-known member
Affected version
2.3.2
Problem:
When viewing a deleted thread, no JavaScript will run on the page due to a JS error in message.js

Error message:
Code:
message.js?_v=b38ec594:901 Uncaught TypeError: Cannot read properties of null (reading 'parentNode')
    at fn.init (message.js?_v=b38ec594:901:73)
    at applyHandler (core.js?_v=b38ec594:9917:8)
    at initializeElement (core.js?_v=b38ec594:9965:5)
    at NodeList.forEach (<anonymous>)
    at Object.initialize (core.js?_v=b38ec594:9978:13)
    at Object.activate (core.js?_v=b38ec594:2137:15)
    at onPageLoad (core.js?_v=b38ec594:938:7)

Fix:
Diff:
Index: js/xf/message.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/xf/message.js b/js/xf/message.js
--- a/js/xf/message.js
+++ b/js/xf/message.js
@@ -898,7 +898,13 @@
                 return
             }
 
-            this.quickReply = document.querySelector('.js-quickReply .js-editor').parentNode
+            const editor = document.querySelector('.js-quickReply .js-editor');
+            if (!editor)
+            {
+                return
+            }
+
+            this.quickReply = editor.parentNode
             if (!this.quickReply)
             {
                 return
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.3).

Change log:
Fix select-to-quote handler error on soft-deleted threads
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom