Merge pull request #3399 from matrix-org/bwindels/fix-formatbar-edit-position

Fix format bar not appearing in edit composer
This commit is contained in:
Bruno Windels 2019-09-06 14:28:23 +00:00 committed by GitHub
commit 14fff3be9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,23 +38,10 @@ export default class MessageComposerFormatBar extends React.PureComponent {
showAt(selectionRect) {
this._formatBarRef.classList.add("mx_MessageComposerFormatBar_shown");
let leftOffset = 0;
let node = this._formatBarRef;
while (node.offsetParent) {
node = node.offsetParent;
leftOffset += node.offsetLeft;
}
let topOffset = 0;
node = this._formatBarRef;
while (node.offsetParent) {
node = node.offsetParent;
topOffset += node.offsetTop;
}
this._formatBarRef.style.left = `${selectionRect.left - leftOffset}px`;
const parentRect = this._formatBarRef.parentElement.getBoundingClientRect();
this._formatBarRef.style.left = `${selectionRect.left - parentRect.left}px`;
// 12 is half the height of the bar (e.g. to center it) and 16 is an offset that felt ok.
this._formatBarRef.style.top = `${selectionRect.top - topOffset - 16 - 12}px`;
this._formatBarRef.style.top = `${selectionRect.top - parentRect.top - 16 - 12}px`;
}
hide() {