Shared:ContextMenu:Fixed the increase in the width of the second level menu on hover, when there is a scroll, or when the theme is dark. Added margins for the second menu level.

This commit is contained in:
Vlada Gazizova 2024-08-13 22:06:56 +03:00
parent fe7c290d38
commit f23d1f7e96

View File

@ -158,13 +158,19 @@ const SubMenu = (props: {
const widthMaxContent = Math.max(...optionsWidth);
if (root) subListWidth = subListWidth || widthMaxContent;
else subListWidth = widthMaxContent;
else if (!subMenuRef?.current?.style.width)
subListWidth = Math.max(subListWidth, widthMaxContent);
}
if (subMenuRef.current) {
let subMenuRefTop = null;
if (!isMobile()) subMenuRef.current.style.width = `${subListWidth}px`;
if (!isMobile()) {
if (root) subMenuRef.current.style.width = `${subListWidth}px`;
else if (!subMenuRef?.current?.style.width) {
subMenuRef.current.style.width = `${subListWidth}px`;
}
}
if (!isMobile() && !root) {
const firstList = parentItem?.firstChild as HTMLElement;
@ -218,6 +224,8 @@ const SubMenu = (props: {
} else {
subMenuRef.current.style.left = `${itemOuterWidth}px`;
if (!root) subMenuRef.current.style.marginLeft = `4px`;
if (!root && subListWidth > freeSpaceRight) {
// If the menu extends beyond the screen
const newWidth = freeSpaceRight - 3 * submenuListMargin;
@ -236,6 +244,8 @@ const SubMenu = (props: {
if (notEnoughWidthRight && freeSpaceLeft > freeSpaceRight) {
subMenuRef.current.style.left = `${-1 * subListWidth}px`;
if (!root) subMenuRef.current.style.marginLeft = `-4px`;
if (
notEnoughWidthRight &&
!root &&