You've already forked AstralRinth
forked from didirus/AstralRinth
fix: keybind issues with gallery + moderation checklist (#4674)
This commit is contained in:
@@ -92,7 +92,7 @@ import {
|
|||||||
XIcon,
|
XIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { Button, Card } from '@modrinth/ui'
|
import { Button, Card } from '@modrinth/ui'
|
||||||
import { ref } from 'vue'
|
import { onMounted, onUnmounted, ref } from 'vue'
|
||||||
|
|
||||||
import { hide_ads_window, show_ads_window } from '@/helpers/ads.js'
|
import { hide_ads_window, show_ads_window } from '@/helpers/ads.js'
|
||||||
import { trackEvent } from '@/helpers/analytics'
|
import { trackEvent } from '@/helpers/analytics'
|
||||||
@@ -151,17 +151,26 @@ const expandImage = (item, index) => {
|
|||||||
|
|
||||||
function keyListener(e) {
|
function keyListener(e) {
|
||||||
if (expandedGalleryItem.value) {
|
if (expandedGalleryItem.value) {
|
||||||
e.preventDefault()
|
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
|
e.preventDefault()
|
||||||
hideImage()
|
hideImage()
|
||||||
} else if (e.key === 'ArrowLeft') {
|
} else if (e.key === 'ArrowLeft') {
|
||||||
|
e.preventDefault()
|
||||||
previousImage()
|
previousImage()
|
||||||
} else if (e.key === 'ArrowRight') {
|
} else if (e.key === 'ArrowRight') {
|
||||||
|
e.preventDefault()
|
||||||
nextImage()
|
nextImage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document.addEventListener('keypress', keyListener)
|
|
||||||
|
onMounted(() => {
|
||||||
|
document.addEventListener('keydown', keyListener)
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
document.removeEventListener('keydown', keyListener)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -631,6 +631,7 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
window.removeEventListener('keydown', handleKeybinds)
|
||||||
notifications.setNotificationLocation('right')
|
notifications.setNotificationLocation('right')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user