Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Improve context menu sizes management

Smaug673991069dbe9757
diff --git a/frontend/app/components/ContextMenuManager.vue b/frontend/app/components/ContextMenuManager.vue
index 676015ff..ee37adff 100644
--- a/frontend/app/components/ContextMenuManager.vue
+++ b/frontend/app/components/ContextMenuManager.vue
@@ -1,10 +1,10 @@
<template>
<div v-if="menu">
<!-- Backdrop transparent -->
- <div class="context-backdrop" @click="contextMenu.close"></div>
+ <div class="context-backdrop" @click="contextMenu.close" />
<!-- Menu -->
- <div class="context-menu" :style="{ top: menu.y + 'px', left: menu.x + 'px', zIndex: 6000 }">
+ <div ref="menuRef" class="context-menu" :style="{ top: `${pos.y}px`, left: `${pos.x}px` }">
<component :is="menu.component" v-bind="menu.options.props" class="context-menu-content" @close="contextMenu.close" />
</div>
</div>
@@ -13,15 +13,46 @@
<script setup lang="ts">
const contextMenu = useContextMenu();
const menu = contextMenu.menu;
+
+const pos = computed(() => {
+ if (!menu.value) return { x: 0, y: 0 };
+
+ let x = menu.value.x;
+ let y = menu.value.y;
+
+ // Estimated menu dimensions (cannot measure before rendering)
+ const menuWidth = 240;
+ const menuHeight = 380;
+ const pad = 8;
+ const vw = typeof window !== 'undefined' ? window.innerWidth : 1920;
+ const vh = typeof window !== 'undefined' ? window.innerHeight : 1080;
+
+ // Horizontal: if right overflow, open to the left
+ if (x + menuWidth > vw - pad) {
+ x = Math.max(pad, vw - menuWidth - pad);
+ }
+
+ // Vertical: if bottom overflow, open upwards
+ if (y + menuHeight > vh - pad) {
+ y = menu.value.y - menuHeight;
+ if (y < pad) {
+ y = pad;
+ }
+ }
+
+ return { x, y };
+});
</script>
<style scoped lang="scss">
.context-menu {
position: fixed;
- min-width: 250px;
- border-radius: 6px;
+ z-index: 6000;
+ min-width: 240px;
+ border-radius: 12px;
+ border: 1px solid var(--border-color);
background: var(--bg-color);
- box-shadow: 0 2px 10px var(--shadow);
+ box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
overflow: hidden;
}
@@ -36,4 +67,8 @@ const menu = contextMenu.menu;
background: transparent;
inset: 0;
}
+
+:root.dark .context-menu {
+ box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 1px rgba(255, 255, 255, 0.1);
+}
</style>