Fix positioning of the thread context menu (#7918)

This commit is contained in:
Michael Telatynski 2022-03-01 08:32:29 +00:00 committed by GitHub
parent b02d5ecb97
commit 115e17b097
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 38 deletions

View file

@ -260,10 +260,11 @@ export default class ContextMenu extends React.PureComponent<IProps, IState> {
const { windowWidth, windowHeight } = UIStore.instance;
if (contextMenuRect) {
if (position.top !== undefined) {
position.top = Math.min(
position.top,
windowHeight - contextMenuRect.height - WINDOW_PADDING,
);
let maxTop = windowHeight - WINDOW_PADDING;
if (!this.props.bottomAligned) {
maxTop -= contextMenuRect.height;
}
position.top = Math.min(position.top, maxTop);
// Adjust the chevron if necessary
if (chevronOffset.top !== undefined) {
chevronOffset.top = props.chevronOffset + props.top - position.top;
@ -278,10 +279,11 @@ export default class ContextMenu extends React.PureComponent<IProps, IState> {
}
}
if (position.left !== undefined) {
position.left = Math.min(
position.left,
windowWidth - contextMenuRect.width - WINDOW_PADDING,
);
let maxLeft = windowWidth - WINDOW_PADDING;
if (!this.props.rightAligned) {
maxLeft -= contextMenuRect.width;
}
position.left = Math.min(position.left, maxLeft);
if (chevronOffset.left !== undefined) {
chevronOffset.left = props.chevronOffset + props.left - position.left;
}