mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 18:30:53 +00:00
fix menu position (#6611)
This commit is contained in:
@@ -14,6 +14,8 @@ const propTypes = {
|
||||
getMenuContainerSize: PropTypes.func,
|
||||
};
|
||||
|
||||
const MENU_BORDER_INDENT = 10;
|
||||
|
||||
class ContextMenu extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
@@ -155,8 +157,12 @@ class ContextMenu extends React.Component {
|
||||
innerHeight = parseFloat(containerSize.height);
|
||||
}
|
||||
|
||||
if (y + rect.height > innerHeight) {
|
||||
menuStyles.top -= rect.height;
|
||||
if (y + rect.height > innerHeight - MENU_BORDER_INDENT) {
|
||||
menuStyles.top = innerHeight - rect.height - MENU_BORDER_INDENT;
|
||||
}
|
||||
|
||||
if (x + rect.width > innerWidth - MENU_BORDER_INDENT) {
|
||||
menuStyles.left = innerWidth - rect.width - MENU_BORDER_INDENT;
|
||||
}
|
||||
|
||||
if (menuStyles.left < 0) {
|
||||
@@ -167,10 +173,6 @@ class ContextMenu extends React.Component {
|
||||
menuStyles.top = rect.height < innerHeight ? (innerHeight - rect.height) / 2 : 0;
|
||||
}
|
||||
|
||||
if (menuStyles.left + rect.width > innerWidth) {
|
||||
menuStyles.left = innerWidth - rect.width;
|
||||
}
|
||||
|
||||
return menuStyles;
|
||||
};
|
||||
|
||||
|
@@ -129,7 +129,8 @@ class DirColumnView extends React.Component {
|
||||
};
|
||||
|
||||
getMenuContainerSize = () => {
|
||||
return window.getComputedStyle(this.viewModeContainer.current);
|
||||
const { innerWidth, innerHeight } = window;
|
||||
return { width: innerWidth, height: innerHeight };
|
||||
};
|
||||
|
||||
render() {
|
||||
|
@@ -612,14 +612,12 @@ class Records extends Component {
|
||||
renderRecordsBody = ({ containerWidth }) => {
|
||||
const { isGroupView, recordGetterByIndex } = this.props;
|
||||
const { recordMetrics, columnMetrics, colOverScanStartIdx, colOverScanEndIdx } = this.state;
|
||||
const {
|
||||
columns, allColumns, totalWidth, lastFrozenColumnKey, frozenColumnsWidth,
|
||||
} = columnMetrics;
|
||||
const contextMenu = (<ContextMenu isGroupView={isGroupView} recordGetterByIndex={recordGetterByIndex} />);
|
||||
const { columns, allColumns, totalWidth, lastFrozenColumnKey, frozenColumnsWidth } = columnMetrics;
|
||||
const commonProps = {
|
||||
...this.props,
|
||||
columns, allColumns, totalWidth, lastFrozenColumnKey, frozenColumnsWidth,
|
||||
recordMetrics, colOverScanStartIdx, colOverScanEndIdx, contextMenu,
|
||||
recordMetrics, colOverScanStartIdx, colOverScanEndIdx,
|
||||
contextMenu: (<ContextMenu isGroupView={isGroupView} recordGetterByIndex={recordGetterByIndex} />),
|
||||
hasSelectedRecord: this.hasSelectedRecord(),
|
||||
getScrollLeft: this.getScrollLeft,
|
||||
getScrollTop: this.getScrollTop,
|
||||
|
Reference in New Issue
Block a user