Skip to content

Commit

Permalink
fix: prompt key shortcut conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiresviana committed Jul 4, 2020
1 parent de0b8bb commit 0d69fbd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
6 changes: 0 additions & 6 deletions frontend/src/components/Search.vue
Expand Up @@ -136,12 +136,6 @@ export default {
}
},
mounted() {
window.addEventListener("keydown", event => {
if (event.keyCode === 27) {
this.closeHovers()
}
})
this.$refs.result.addEventListener('scroll', event => {
if (event.target.offsetHeight + event.target.scrollTop >= event.target.scrollHeight - 100) {
this.resultsCount += 50
Expand Down
20 changes: 12 additions & 8 deletions frontend/src/components/files/Listing.vue
Expand Up @@ -101,7 +101,7 @@ export default {
components: { Item },
data: function () {
return {
show: 50,
showLimit: 50,
uploading: {
id: 0,
count: 0,
Expand All @@ -111,7 +111,7 @@ export default {
}
},
computed: {
...mapState(['req', 'selected', 'user']),
...mapState(['req', 'selected', 'user', 'show']),
nameSorted () {
return (this.req.sorting.by === 'name')
},
Expand Down Expand Up @@ -139,14 +139,14 @@ export default {
return { dirs, files }
},
dirs () {
return this.items.dirs.slice(0, this.show)
return this.items.dirs.slice(0, this.showLimit)
},
files () {
let show = this.show - this.items.dirs.length
let showLimit = this.showLimit - this.items.dirs.length
if (show < 0) show = 0
if (showLimit < 0) showLimit = 0
return this.items.files.slice(0, show)
return this.items.files.slice(0, showLimit)
},
nameIcon () {
if (this.nameSorted && !this.ascOrdered) {
Expand Down Expand Up @@ -194,7 +194,11 @@ export default {
base64: function (name) {
return window.btoa(unescape(encodeURIComponent(name)))
},
keyEvent (event) {
keyEvent (event) {
if (this.show !== null) {
return
}
if (!event.ctrlKey && !event.metaKey) {
return
}
Expand Down Expand Up @@ -292,7 +296,7 @@ export default {
},
scrollEvent () {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
this.show += 50
this.showLimit += 50
}
},
dragEnter () {
Expand Down
16 changes: 12 additions & 4 deletions frontend/src/views/Files.vue
Expand Up @@ -61,7 +61,8 @@ export default {
'user',
'reload',
'multiple',
'loading'
'loading',
'show'
]),
isPreview () {
return !this.loading && !this.isListing && !this.isEditor
Expand Down Expand Up @@ -158,10 +159,17 @@ export default {
}
},
keyEvent (event) {
// Esc!
if (event.keyCode === 27) {
this.$store.commit('closeHovers')
if (this.show !== null) {
// Esc!
if (event.keyCode === 27) {
this.$store.commit('closeHovers')
}
return
}
// Esc!
if (event.keyCode === 27) {
// If we're on a listing, unselect all
// files and folders.
if (this.isListing) {
Expand Down

0 comments on commit 0d69fbd

Please sign in to comment.