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
fix: menu not closing on escape or click away
thecodrraeca26036710
diff --git a/apps/web/src/components/global-menu-wrapper/index.js b/apps/web/src/components/global-menu-wrapper/index.jsindex f55e15916..f0f7791b1 100644--- a/apps/web/src/components/global-menu-wrapper/index.js+++ b/apps/web/src/components/global-menu-wrapper/index.js@@ -27,8 +27,10 @@ function GlobalMenuWrapper() {{...props}style={{...props.style,+ zIndex: 1000,backgroundColor: isAutocomplete ? "transparent" : "unset",}}+ onClick={(e) => closeMenu()}onContextMenu={(e) => {e.preventDefault();closeMenu();@@ -47,13 +49,6 @@ function GlobalMenuWrapper() {contentElement={(props, children) => (<Box{...props}- onKeyDown={(e) => {- if (props.onKeyDown) props.onKeyDown(e);- if (e.key === "Escape") {- e.stopPropagation();- e.preventDefault();- }- }}style={{}}sx={{top: 0,diff --git a/apps/web/src/components/menu/index.js b/apps/web/src/components/menu/index.jsindex 63748c349..5b65014c6 100644--- a/apps/web/src/components/menu/index.js+++ b/apps/web/src/components/menu/index.js@@ -5,7 +5,7 @@ import { FlexScrollContainer } from "../scroll-container";import MenuItem from "./menu-item";import { store as selectionStore } from "../../stores/selection-store";-function useMenuFocus(items, onAction) {+function useMenuFocus(items, onAction, onClose) {const [focusIndex, setFocusIndex] = useState(-1);const [isSubmenuOpen, setIsSubmenuOpen] = useState(false);@@ -61,6 +61,9 @@ function useMenuFocus(items, onAction) {case "Enter":onAction && onAction(e);break;+ case "Escape":+ onClose && onClose(e);+ break;default:break;}@@ -98,10 +101,14 @@ function Menu({ items, data, title, closeMenu }) {);const [focusIndex, setFocusIndex, isSubmenuOpen, setIsSubmenuOpen] =- useMenuFocus(items, (e) => {- const item = items[focusIndex];- if (item) onAction(e, item);- });+ useMenuFocus(+ items,+ (e) => {+ const item = items[focusIndex];+ if (item) onAction(e, item);+ },+ () => closeMenu()+ );const subMenuRef = useRef();useEffect(() => {@@ -200,7 +207,11 @@ function MenuContainer({ title, children }) {color="primary"py={"8px"}px={3}- sx={{ borderBottom: "1px solid", borderBottomColor: "border" }}+ sx={{+ borderBottom: "1px solid",+ borderBottomColor: "border",+ wordWrap: "break-word",+ }}>{title}</Text>