mirror of https://github.com/vector-im/riot-web
Merge pull request #3399 from matrix-org/bwindels/fix-formatbar-edit-position
Fix format bar not appearing in edit composerpull/21833/head
commit
14fff3be9a
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue