From 29add31619359b341c70530592274e17fb439db9 Mon Sep 17 00:00:00 2001 From: Sunhwan Jo Date: Mon, 22 Mar 2021 10:21:56 -0700 Subject: [PATCH 1/4] deactivate top menu bar when mouse leaves --- src/components/MenuBar.vue | 14 ++++++++++++++ src/components/MenuBarItem.vue | 12 ++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/components/MenuBar.vue b/src/components/MenuBar.vue index bb72504..a90f6b0 100644 --- a/src/components/MenuBar.vue +++ b/src/components/MenuBar.vue @@ -35,6 +35,7 @@ :is-touch-device="isMobileDevice" :on-selected="handleSelected" :highlight-first-element="highlightFirstElement" + @deactivate="handleDeactivateMenu" @activate="handleActivateMenu" @activate-next="handleActivateDir" @activate-previous="handleActivateDir" @@ -186,6 +187,7 @@ export default defineComponent({ activeMenuSelection.value = -1; activeMenuBarId.value = ""; highlightFirstElement.value = false; + handleDeactivateMenu(); } }; @@ -303,6 +305,17 @@ export default defineComponent({ ); }; + const handleDeactivateMenu = (id?: string) => { + // keep the menubar when the sub menu is being displayed + if (!menuActive.value) { + menuItems.value = menuItems.value.map((item) => + Object.assign({}, item, { + showMenu: false, + }) + ); + } + }; + const handleOnShowMenu = (state: boolean, id: string) => { menuActive.value = state; if (state) { @@ -374,6 +387,7 @@ export default defineComponent({ expandClass, handleActivateDir, handleActivateMenu, + handleDeactivateMenu, handleDrag, handleDragCancel, handleDragEnd, diff --git a/src/components/MenuBarItem.vue b/src/components/MenuBarItem.vue index 96dbdda..4f9ce13 100644 --- a/src/components/MenuBarItem.vue +++ b/src/components/MenuBarItem.vue @@ -4,7 +4,8 @@ :class="[...menuBarStyle, 'menu-bar-item-container']" :style="{ background: bgColor }" tabindex="0" - @mouseenter="setMenuViewable()" + @mouseenter="setMenuViewable(true)" + @mouseleave="setMenuViewable(false)" @keyup="handleKeyUp" > emit("activate", props.id); + const setMenuViewable = (viewable: boolean) => { + if (viewable) { + emit("activate", props.id); + } else { + emit("deactivate", props.id); + } + } // toggle menu const toggleMenu = (event: MouseEvent | TouchEvent) => { From 275a6057f72db1f94ad4369bf6159ce29da6f7c7 Mon Sep 17 00:00:00 2001 From: Sunhwan Jo Date: Tue, 23 Mar 2021 21:25:45 -0700 Subject: [PATCH 2/4] removed id argument from handleDeativateMenu method --- src/components/MenuBar.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MenuBar.vue b/src/components/MenuBar.vue index a90f6b0..7fb17b4 100644 --- a/src/components/MenuBar.vue +++ b/src/components/MenuBar.vue @@ -305,7 +305,7 @@ export default defineComponent({ ); }; - const handleDeactivateMenu = (id?: string) => { + const handleDeactivateMenu = () => { // keep the menubar when the sub menu is being displayed if (!menuActive.value) { menuItems.value = menuItems.value.map((item) => From c424661949868f14763837bb8b17cd4aa76ac608 Mon Sep 17 00:00:00 2001 From: Prabhu Date: Wed, 24 Mar 2021 22:27:47 +0530 Subject: [PATCH 3/4] fixing deepsource issues --- src/components/MenuBar.vue | 2 ++ src/components/MenuBarItem.vue | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/MenuBar.vue b/src/components/MenuBar.vue index 7fb17b4..9d8b31e 100644 --- a/src/components/MenuBar.vue +++ b/src/components/MenuBar.vue @@ -335,6 +335,8 @@ export default defineComponent({ dockPosition.value === DockPosition.RIGHT ) { return menuBarActive.value ? "expanded" : "not-expanded"; + } else { + return ""; } }); diff --git a/src/components/MenuBarItem.vue b/src/components/MenuBarItem.vue index 4f9ce13..c36fd56 100644 --- a/src/components/MenuBarItem.vue +++ b/src/components/MenuBarItem.vue @@ -179,7 +179,7 @@ export default defineComponent({ const highlightIndex = ref(-1); const computeMenuStyle = () => { - let newStyle: { + const newStyle: { top?: string; left?: string; right?: string; From 6e11a85a95f5a0de1ab98b3f13ad296fa75a8ddf Mon Sep 17 00:00:00 2001 From: Prabhu Date: Wed, 24 Mar 2021 22:31:00 +0530 Subject: [PATCH 4/4] fixes another deepscan bug --- src/components/MenuBar.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MenuBar.vue b/src/components/MenuBar.vue index 9d8b31e..eb3d1c2 100644 --- a/src/components/MenuBar.vue +++ b/src/components/MenuBar.vue @@ -362,7 +362,7 @@ export default defineComponent({ menuItems.value = result.navigateMenu.items; } else if ("navigateMenubar" in result) { highlightFirstElement.value = true; - let { + const { navigateMenubar: { nextId }, } = result; activeMenuBarId.value = nextId;