Skip to content

Commit cbdad9c

Browse files
authored
fix[TagsView]: fix openMenu boundary display bug (PanJiaChen#1256)
1 parent 1a345a7 commit cbdad9c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/views/layout/components/TagsView.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,21 @@ export default {
121121
this.$router.push('/')
122122
},
123123
openMenu(tag, e) {
124-
this.visible = true
125-
this.selectedTag = tag
124+
const menuMinWidth = 105
126125
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
127-
this.left = e.clientX - offsetLeft + 15 // 15: margin right
126+
const offsetWidth = this.$el.offsetWidth // container width
127+
const maxLeft = offsetWidth - menuMinWidth // left boundary
128+
const left = e.clientX - offsetLeft + 15 // 15: margin right
129+
130+
if (left > maxLeft) {
131+
this.left = maxLeft
132+
} else {
133+
this.left = left
134+
}
128135
this.top = e.clientY
136+
137+
this.visible = true
138+
this.selectedTag = tag
129139
},
130140
closeMenu() {
131141
this.visible = false

0 commit comments

Comments
 (0)