From 4a7bc74e9991c457f4bfac099cca382650ac7880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 9 Feb 2021 19:46:30 +0100 Subject: [PATCH] Fix duplication of codeblock elements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/views/messages/TextualBody.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index 71f7572a25..e3cd9d8f51 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -96,6 +96,9 @@ export default class TextualBody extends React.Component { const pres = ReactDOM.findDOMNode(this).getElementsByTagName("pre"); if (pres.length > 0) { for (let i = 0; i < pres.length; i++) { + // If there already is a div wrapping the codeblock we want to skip this. + // This happens after the codeblock was edited. + if (pres[i].parentNode.className == "mx_EventTile_pre_container") continue; // Wrap a div around
 so that the copy button can be correctly positioned
                     // when the 
 overflows and is scrolled horizontally.
                     const div = this._wrapInDiv(pres[i]);