Browse Source

fix(nc-gui): tests

pull/7625/head
DarkPhoenix2704 9 months ago
parent
commit
519c4b5050
  1. 1
      packages/nc-gui/app.vue
  2. 22
      packages/nc-gui/components/cmd-l/index.vue

1
packages/nc-gui/app.vue

@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { applyNonSelectable, computed, isEeUI, isMac, useCommandPalette, useRouter, useTheme } from '#imports' import { applyNonSelectable, computed, isEeUI, isMac, useCommandPalette, useRouter, useTheme } from '#imports'
import type { CommandPaletteType } from '~/lib' import type { CommandPaletteType } from '~/lib'
const router = useRouter() const router = useRouter()
const route = router.currentRoute const route = router.currentRoute

22
packages/nc-gui/components/cmd-l/index.vue

@ -132,10 +132,12 @@ const hide = () => {
} }
onClickOutside(modalEl, () => { onClickOutside(modalEl, () => {
search.value = ''
if (vOpen.value) hide() if (vOpen.value) hide()
}) })
const onKeyDown = (e: KeyboardEvent) => { useEventListener('keydown', (e: KeyboardEvent) => {
console.log(e.key)
if (e.key === 'Escape') { if (e.key === 'Escape') {
hide() hide()
} else if (e.key === 'Enter') { } else if (e.key === 'Enter') {
@ -152,14 +154,16 @@ const onKeyDown = (e: KeyboardEvent) => {
moveDown() moveDown()
} else if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key === 'l') { } else if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key === 'l') {
if (!user.value) return if (!user.value) return
e.preventDefault() if (!vOpen.value) {
if (!vOpen.value) vOpen.value = true vOpen.value = true
moveUp() } else {
moveUp()
}
} else if ((e.metaKey || e.ctrlKey) && e.key === 'l') { } else if ((e.metaKey || e.ctrlKey) && e.key === 'l') {
if (!user.value) return if (!user.value) return
e.preventDefault() if (!vOpen.value) {
if (!vOpen.value) vOpen.value = true vOpen.value = true
moveDown() } else moveDown()
} else if ((e.ctrlKey || e.metaKey) && e.key === 'k') { } else if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
hide() hide()
} else if ((e.ctrlKey || e.metaKey) && e.key === 'j') { } else if ((e.ctrlKey || e.metaKey) && e.key === 'j') {
@ -167,7 +171,7 @@ const onKeyDown = (e: KeyboardEvent) => {
} else if (vOpen.value) { } else if (vOpen.value) {
cmdInputEl.value?.focus() cmdInputEl.value?.focus()
} }
} })
onMounted(() => { onMounted(() => {
document.querySelector('.cmdOpt-list')?.focus() document.querySelector('.cmdOpt-list')?.focus()
@ -180,8 +184,6 @@ onMounted(() => {
} else { } else {
selected.value = filteredViews.value[index + 1].tableID + filteredViews.value[index + 1].viewName selected.value = filteredViews.value[index + 1].tableID + filteredViews.value[index + 1].viewName
} }
window.addEventListener('keydown', onKeyDown)
}) })
</script> </script>

Loading…
Cancel
Save