fix: keybind issues with gallery + moderation checklist (#4674)

This commit is contained in:
Calum H.
2025-10-30 21:20:16 +00:00
committed by GitHub
parent c74460fffa
commit 8b39ba491a
2 changed files with 13 additions and 3 deletions

View File

@@ -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">

View File

@@ -631,6 +631,7 @@ onMounted(() => {
}) })
onUnmounted(() => { onUnmounted(() => {
window.removeEventListener('keydown', handleKeybinds)
notifications.setNotificationLocation('right') notifications.setNotificationLocation('right')
}) })