Flatten threads: remove the additional info element in the edit box
The flatten threads feature needs to inject an element with additional
information about the message to the message payload, which is hidden
via an inline CSS style. However, when the Community Console renders the
edit box, this style is removed and the additional information is
visible in the reply box.
This CL fixes this by removing this element from the reply box when
found.
Bug: twpowertools:156
Change-Id: I9eb5a965926fef91374396304e12837d5ef5c798
diff --git a/src/contentScripts/communityConsole/flattenThreads/flattenThreads.js b/src/contentScripts/communityConsole/flattenThreads/flattenThreads.js
index d99ddc6..e8585d0 100644
--- a/src/contentScripts/communityConsole/flattenThreads/flattenThreads.js
+++ b/src/contentScripts/communityConsole/flattenThreads/flattenThreads.js
@@ -74,4 +74,13 @@
shouldInjectReplyBtn(node) {
return node.matches(kReplyActionButtonsSelector);
}
+
+ deleteAdditionalInfoElementIfApplicable(node) {
+ if (!node.closest('sc-tailwind-shared-rich-text-editor')) return;
+ node.remove();
+ }
+
+ isAdditionalInfoElement(node) {
+ return node.matches(kAdditionalInfoSelector);
+ }
}
diff --git a/src/contentScripts/communityConsole/main.js b/src/contentScripts/communityConsole/main.js
index 2061834..0e53917 100644
--- a/src/contentScripts/communityConsole/main.js
+++ b/src/contentScripts/communityConsole/main.js
@@ -1,5 +1,5 @@
import {injectScript, injectStyles, injectStylesheet} from '../../common/contentScriptsUtils.js';
-import {getOptions, isOptionEnabled} from '../../common/optionsUtils.js';
+import {getOptions} from '../../common/optionsUtils.js';
import {injectPreviousPostsLinksUnifiedProfileIfEnabled} from '../utilsCommon/unifiedProfiles.js';
import AvatarsHandler from './avatars.js';
@@ -228,6 +228,11 @@
if (flattenThreads.shouldInjectReplyBtn(node)) {
flattenThreads.injectReplyBtnIfApplicable(node);
}
+
+ // Delete additional info in the edit message box
+ if (flattenThreads.isAdditionalInfoElement(node)) {
+ flattenThreads.deleteAdditionalInfoElementIfApplicable(node);
+ }
}
}