Open create submenu beside context menu and distinguish rename icons
This commit is contained in:
1 parent
c05293a948
commit
1afa755d4f
9 files changed
+193
-26
No files matched your search
@@ -17,7 +17,8 @@
|
||||
</Teleport>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, nextTick, onBeforeUnmount } from "vue";
|
||||
import { ref, watch, nextTick, onBeforeUnmount, provide, useId } from "vue";
|
||||
import { contextMenuKey } from "@/utils/context-menu";
|
||||
const emit = defineEmits(["hide"]);
|
||||
const props = defineProps<{ show: boolean; pos: { x: number; y: number } }>();
|
||||
const contextMenu = ref<HTMLElement | null>(null),
|
||||
@@ -25,6 +26,8 @@ const contextMenu = ref<HTMLElement | null>(null),
|
||||
top = ref(0);
|
||||
let previousFocus: HTMLElement | null = null;
|
||||
const hide = () => emit("hide");
|
||||
const menuId = useId();
|
||||
provide(contextMenuKey, { id: menuId, close: hide });
|
||||
function menuClick(event: MouseEvent) {
|
||||
if (
|
||||
event.target instanceof Element &&
|
||||
@@ -50,6 +53,13 @@ async function schedulePosition() {
|
||||
position();
|
||||
}
|
||||
function outside(event: Event) {
|
||||
if (
|
||||
event.target instanceof Element &&
|
||||
event.target
|
||||
.closest("[data-context-owner]")
|
||||
?.getAttribute("data-context-owner") === menuId
|
||||
)
|
||||
return;
|
||||
if (
|
||||
event.target instanceof Node &&
|
||||
!contextMenu.value?.contains(event.target)
|
||||
|
||||
Reference in new issue
Block a user