fix: position of float menu

This commit is contained in:
gaze 2023-08-22 12:36:36 +08:00
parent 1c104f6a9e
commit 0dd8314153
7 changed files with 17 additions and 13 deletions

View File

@ -1386,7 +1386,6 @@ export function handleContextMenu(
ctx: Context,
settings: Settings,
e: MouseEvent,
workbookContainer: HTMLDivElement,
container: HTMLDivElement,
area: "cell" | "rowHeader" | "columnHeader"
) {
@ -1400,7 +1399,6 @@ export function handleContextMenu(
// //非编辑模式下禁止右键功能框
// return;
// }
const workbookRect = workbookContainer.getBoundingClientRect();
const { cellContextMenu } = settings;
@ -1420,8 +1418,8 @@ export function handleContextMenu(
}
// relative to the workbook container
const x = e.pageX - workbookRect.left + workbookRect.x;
const y = e.pageY - workbookRect.top + workbookRect.y;
const x = e.pageX;
const y = e.pageY;
// showrightclickmenu($("#luckysheet-rightclick-menu"), x, y);
ctx.contextMenu = {
x,

View File

@ -429,7 +429,11 @@ const FilterMenu: React.FC = () => {
className="fortune-context-menu luckysheet-cols-menu fortune-filter-menu"
id="luckysheet-\${menuid}-menu"
ref={containerRef}
style={{ left: filterContextMenu.x, top: filterContextMenu.y }}
style={{
left: filterContextMenu.x,
top: filterContextMenu.y,
position: "fixed",
}}
>
{settings.filterContextMenu?.map((name, i) => {
if (name === "|") {

View File

@ -104,7 +104,12 @@ const SheetTabContextMenu: React.FC = () => {
<div
className="fortune-context-menu luckysheet-cols-menu"
onContextMenu={(e) => e.stopPropagation()}
style={{ left: position.x, top: position.y, overflow: "visible" }}
style={{
left: position.x,
top: position.y,
overflow: "visible",
position: "fixed",
}}
ref={containerRef}
>
{settings.sheetTabContextMenu?.map((name, i) => {

View File

@ -673,7 +673,7 @@ const ContextMenu: React.FC = () => {
className="fortune-context-menu luckysheet-cols-menu"
ref={containerRef}
onContextMenu={(e) => e.stopPropagation()}
style={{ left: contextMenu.x, top: contextMenu.y }}
style={{ left: contextMenu.x, top: contextMenu.y, position: "fixed" }}
>
{context.contextMenu.headerMenu === true
? settings.headerContextMenu.map((menu, i) => getMenuElement(menu, i))

View File

@ -154,13 +154,12 @@ const ColumnHeader: React.FC = () => {
draftCtx,
settings,
nativeEvent,
refs.workbookContainer.current!,
refs.cellArea.current!,
"columnHeader"
);
});
},
[refs.workbookContainer, setContext, settings, refs.cellArea]
[setContext, settings, refs.cellArea]
);
useEffect(() => {

View File

@ -143,13 +143,12 @@ const RowHeader: React.FC = () => {
draftCtx,
settings,
nativeEvent,
refs.workbookContainer.current!,
refs.cellArea.current!,
"rowHeader"
);
});
},
[refs.workbookContainer, setContext, settings, refs.cellArea]
[setContext, settings, refs.cellArea]
);
useEffect(() => {

View File

@ -103,13 +103,12 @@ const SheetOverlay: React.FC = () => {
draftCtx,
settings,
nativeEvent,
refs.workbookContainer.current!,
refs.cellArea.current!,
"cell"
);
});
},
[refs.workbookContainer, setContext, settings, refs.cellArea]
[setContext, settings, refs.cellArea]
);
const cellAreaDoubleClick = useCallback(