Shared:ContextMenu:Refactoring.
This commit is contained in:
parent
a0483cbd4c
commit
dd4e3e0255
@ -53,6 +53,8 @@ import { MobileSubMenu } from "./sub-components/MobileSubMenu";
|
|||||||
|
|
||||||
import { ContextMenuModel, ContextMenuProps } from "./ContextMenu.types";
|
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 ContextMenu = React.forwardRef((props: ContextMenuProps, ref) => {
|
||||||
const [visible, setVisible] = React.useState(false);
|
const [visible, setVisible] = React.useState(false);
|
||||||
const [reshow, setReshow] = 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 [showMobileMenu, setShowMobileMenu] = React.useState(false);
|
||||||
const [mobileSubMenuItems, setMobileSubMenuItems] = React.useState<
|
const [mobileSubMenuItems, setMobileSubMenuItems] = React.useState<
|
||||||
ContextMenuModel[] | undefined
|
ContextMenuModel[] | undefined
|
||||||
>(undefined);
|
>([]);
|
||||||
const [mobileHeader, setMobileHeader] = React.useState<string>("");
|
const [mobileHeader, setMobileHeader] = React.useState<string>("");
|
||||||
|
|
||||||
const [articleWidth, setArticleWidth] = React.useState(0);
|
const [articleWidth, setArticleWidth] = React.useState(0);
|
||||||
@ -279,8 +281,6 @@ const ContextMenu = React.forwardRef((props: ContextMenuProps, ref) => {
|
|||||||
|
|
||||||
// fit
|
// fit
|
||||||
if (top < document.body.scrollTop) {
|
if (top < document.body.scrollTop) {
|
||||||
const marginTop = 16;
|
|
||||||
|
|
||||||
if (document.body.scrollTop === 0) top = marginTop;
|
if (document.body.scrollTop === 0) top = marginTop;
|
||||||
else top = document.body.scrollTop;
|
else top = document.body.scrollTop;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,9 @@ import {
|
|||||||
SeparatorType,
|
SeparatorType,
|
||||||
} from "../ContextMenu.types";
|
} from "../ContextMenu.types";
|
||||||
|
|
||||||
|
const submenuListMargin = 4; // Indentation of the second level menu from the first level
|
||||||
|
const sectionPadding = 16; // Screen margin
|
||||||
|
|
||||||
const SubMenu = (props: {
|
const SubMenu = (props: {
|
||||||
model: ContextMenuModel[];
|
model: ContextMenuModel[];
|
||||||
root?: boolean;
|
root?: boolean;
|
||||||
@ -185,8 +188,6 @@ const SubMenu = (props: {
|
|||||||
const freeSpaceRight =
|
const freeSpaceRight =
|
||||||
viewport.width - containerOffsetLeft - itemOuterWidth;
|
viewport.width - containerOffsetLeft - itemOuterWidth;
|
||||||
const freeSpaceLeft = containerOffsetLeft;
|
const freeSpaceLeft = containerOffsetLeft;
|
||||||
const submenuListMargin = 4;
|
|
||||||
const sectionPadding = 16;
|
|
||||||
|
|
||||||
if (isRtl) {
|
if (isRtl) {
|
||||||
if (
|
if (
|
||||||
|
Loading…
Reference in New Issue
Block a user