A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: fix invalid submenu position due to element id conflict (#1977)
Abdullah Attadf78b31527c4
diff --git a/apps/web/src/components/menu/index.js b/apps/web/src/components/menu/index.jsindex 399d2c9c5..1238485ec 100644--- a/apps/web/src/components/menu/index.js+++ b/apps/web/src/components/menu/index.js@@ -24,6 +24,9 @@ import { FlexScrollContainer } from "../scroll-container";import MenuItem from "./menu-item";import { store as selectionStore } from "../../stores/selection-store";+function getMenuItemId(item) {+ return `menuitem-${item.key}`;+}function useMenuFocus(items, onAction, onClose) {const [focusIndex, setFocusIndex] = useState(-1);const [isSubmenuOpen, setIsSubmenuOpen] = useState(false);@@ -32,7 +35,7 @@ function useMenuFocus(items, onAction, onClose) {(index) => {const item = items[index];if (!item) return;- const element = document.getElementById(item.key);+ const element = document.getElementById(getMenuItemId(item));if (!element) return;element.scrollIntoView({behavior: "auto"@@ -146,7 +149,7 @@ function Menu({ items, data, title, closeMenu }) {const { top, left } = getPosition(subMenuRef.current, {yOffset: 0,- relativeTo: document.getElementById(item.key),+ relativeTo: document.getElementById(getMenuItemId(item)),location: "right"});diff --git a/apps/web/src/components/menu/menu-item.js b/apps/web/src/components/menu/menu-item.jsindex f4f669c6c..af918ba3e 100644--- a/apps/web/src/components/menu/menu-item.js+++ b/apps/web/src/components/menu/menu-item.js@@ -50,12 +50,12 @@ function MenuItem({ item, isFocused, onMouseEnter, onMouseLeave, onClick }) {return (<Flexas="li"+ id={`menuitem-${key}`}onMouseEnter={onMouseEnter}onMouseLeave={onMouseLeave}sx={{ flex: 1, flexDirection: "column" }}><Button- id={key}data-test-id={`menuitem-${key}`}key={key}ref={itemRef}