Browse Source

refactor(gui-v2): use `useEventListener` for binding event handler

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3005/head
Pranav C 2 years ago
parent
commit
91565b0ce7
  1. 10
      packages/nc-gui-v2/components/smartsheet/Grid.vue

10
packages/nc-gui-v2/components/smartsheet/Grid.vue

@ -1,12 +1,11 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onClickOutside } from '@vueuse/core' import { onClickOutside, useEventListener } from '@vueuse/core'
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import { isVirtualCol } from 'nocodb-sdk' import { isVirtualCol } from 'nocodb-sdk'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { import {
inject, inject,
onMounted, onMounted,
onUnmounted,
provide, provide,
useGridViewColumnWidth, useGridViewColumnWidth,
useProvideColumnCreateStore, useProvideColumnCreateStore,
@ -227,12 +226,7 @@ const onKeyDown = async (e: KeyboardEvent) => {
} }
} }
onMounted(() => { useEventListener(document, 'keydown', onKeyDown)
document.addEventListener('keydown', onKeyDown)
})
onUnmounted(() => {
document.removeEventListener('keydown', onKeyDown)
})
/** On clicking outside of table reset active cell */ /** On clicking outside of table reset active cell */
const smartTable = ref(null) const smartTable = ref(null)

Loading…
Cancel
Save