Shared:ContextMenu:Refactoring.

This commit is contained in:
Vlada Gazizova 2024-06-07 13:23:20 +03:00
parent a0483cbd4c
commit dd4e3e0255
2 changed files with 6 additions and 5 deletions

View File

@ -53,6 +53,8 @@ import { MobileSubMenu } from "./sub-components/MobileSubMenu";
import { ContextMenuModel, ContextMenuProps } from "./ContextMenu.types";
const marginTop = 16; // Indentation from the top border of the screen
const ContextMenu = React.forwardRef((props: ContextMenuProps, ref) => {
const [visible, setVisible] = React.useState(false);
const [reshow, setReshow] = React.useState(false);
@ -62,7 +64,7 @@ const ContextMenu = React.forwardRef((props: ContextMenuProps, ref) => {
const [showMobileMenu, setShowMobileMenu] = React.useState(false);
const [mobileSubMenuItems, setMobileSubMenuItems] = React.useState<
ContextMenuModel[] | undefined
>(undefined);
>([]);
const [mobileHeader, setMobileHeader] = React.useState<string>("");
const [articleWidth, setArticleWidth] = React.useState(0);
@ -279,8 +281,6 @@ const ContextMenu = React.forwardRef((props: ContextMenuProps, ref) => {
// fit
if (top < document.body.scrollTop) {
const marginTop = 16;
if (document.body.scrollTop === 0) top = marginTop;
else top = document.body.scrollTop;
}

View File

@ -46,6 +46,9 @@ import {
SeparatorType,
} from "../ContextMenu.types";
const submenuListMargin = 4; // Indentation of the second level menu from the first level
const sectionPadding = 16; // Screen margin
const SubMenu = (props: {
model: ContextMenuModel[];
root?: boolean;
@ -185,8 +188,6 @@ const SubMenu = (props: {
const freeSpaceRight =
viewport.width - containerOffsetLeft - itemOuterWidth;
const freeSpaceLeft = containerOffsetLeft;
const submenuListMargin = 4;
const sectionPadding = 16;
if (isRtl) {
if (