Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

Ensure context menu doesn't clip off the screen

aterox8ee784764891
diff --git a/src/components/LinkItems/SectionContextMenu.vue b/src/components/LinkItems/SectionContextMenu.vue
index 8f9b12c1..7f7d16e7 100644
--- a/src/components/LinkItems/SectionContextMenu.vue
+++ b/src/components/LinkItems/SectionContextMenu.vue
@@ -1,7 +1,7 @@
<template>
<transition name="slide">
<div class="context-menu" v-if="show && !isMenuDisabled"
- :style="posX && posY ? `top:${posY}px;left:${posX}px;` : ''">
+ :style="posX && posY ? calcPosition() : ''">
<!-- Open Options -->
<ul class="menu-section">
<li @click="openSection()">
@@ -59,6 +59,13 @@ export default {
removeSection() {
this.$emit('removeSection');
},
+ calcPosition() {
+ const bounds = this.$parent.$el.getBoundingClientRect();
+ const left = this.posX < (bounds.right + bounds.left) / 2;
+ const position = `top:${this.posY}px;${left ? 'left' : 'right'}:\
+ ${left ? this.posX : document.documentElement.clientWidth - this.posX}px;`;
+ return position;
+ },
},
};
</script>