Fix incorrectly positioned copy button on <pre> blocks

This commit is contained in:
Luke Barnard 2018-06-27 11:31:55 +01:00
parent 4c575bb1ca
commit 6345fcb8f2
2 changed files with 19 additions and 3 deletions

View file

@ -340,7 +340,18 @@ module.exports = React.createClass({
}, false);
e.target.onmouseleave = close;
};
p.appendChild(button);
// Wrap a div around <pre> so that the copy button can be correctly positioned
// when the <pre> overflows and is scrolled horizontally.
const div = document.createElement("div");
div.className = "mx_EventTile_pre_container";
// Insert containing div in place of <pre> block
p.parentNode.replaceChild(div, p);
// Append <pre> block and copy button to container
div.appendChild(p);
div.appendChild(button);
});
},