Fix clicking on menu bar sub-menu entries (#337)

* Fix a bug where clicking a submenu would cause the parent menu to be closed before the submenu click could be registered. Also ignores package-lock.json.

* Remove package-lock gitignore

* Add back empty line
This commit is contained in:
Keaton Brandt 2021-08-10 17:54:09 -04:00 committed by Keavon Chambers
parent b7976219f3
commit 74d0e6dbc0

View file

@ -332,15 +332,16 @@ export default defineComponent({
window.removeEventListener("click", this.clickHandlerCapture, true);
},
isMouseEventOutsideFloatingMenu(e: MouseEvent, extraDistanceAllowed = 0): boolean {
const floatingMenuContent = this.$refs.floatingMenuContent as HTMLElement;
if (!floatingMenuContent) return true;
const floatingMenuBounds = floatingMenuContent.getBoundingClientRect();
// Considers all child menus as well as the top-level one.
const allContainedFloatingMenus = [...this.$el.querySelectorAll(".floating-menu-content")];
return !allContainedFloatingMenus.find((element) => !this.isMouseEventOutsideMenuElement(e, element, extraDistanceAllowed));
},
isMouseEventOutsideMenuElement(e: MouseEvent, element: HTMLElement, extraDistanceAllowed = 0): boolean {
const floatingMenuBounds = element.getBoundingClientRect();
if (floatingMenuBounds.left - e.clientX >= extraDistanceAllowed) return true;
if (e.clientX - floatingMenuBounds.right >= extraDistanceAllowed) return true;
if (floatingMenuBounds.top - e.clientY >= extraDistanceAllowed) return true;
if (e.clientY - floatingMenuBounds.bottom >= extraDistanceAllowed) return true;
return false;
},
},