Browse Source

fix: avoid opening dropdown on cmd/alt/shift/ctrl key press

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4514/head
Pranav C 2 years ago
parent
commit
0d13701bfe
  1. 2
      packages/nc-gui/components/cell/MultiSelect.vue
  2. 6
      packages/nc-gui/components/cell/SingleSelect.vue
  3. 12
      packages/nc-gui/composables/useMultiSelect/index.ts

2
packages/nc-gui/components/cell/MultiSelect.vue

@ -180,7 +180,7 @@ useSelectedCellKeyupListener(active, (e) => {
break
default:
// toggle only if char key pressed
if (e.key?.length === 1) {
if (!(e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) && e.key?.length === 1) {
e.stopPropagation()
isOpen.value = true
}

6
packages/nc-gui/components/cell/SingleSelect.vue

@ -106,7 +106,7 @@ useSelectedCellKeyupListener(active, (e) => {
break
default:
// toggle only if char key pressed
if (e.key?.length === 1) {
if (!(e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) && e.key?.length === 1) {
e.stopPropagation()
isOpen.value = true
}
@ -143,7 +143,7 @@ async function addIfMissingAndSave() {
// Mysql escapes single quotes with backslash so we keep quotes but others have to unescaped
if (!isMysql.value) {
updatedColMeta.cdf = updatedColMeta.cdf.replace(/''/g, "'")
updatedColMeta.cdf = updatedColMeta.cdf.replace(/''/g, '\'')
}
}
@ -153,7 +153,7 @@ async function addIfMissingAndSave() {
)
vModel.value = newOptValue
await getMeta(column.value.fk_model_id!, true)
} catch (e) {
} catch (e: any) {
console.log(e)
message.error(await extractSdkResponseErrorMsg(e))
}

12
packages/nc-gui/composables/useMultiSelect/index.ts

@ -1,5 +1,6 @@
import type { MaybeRef } from '@vueuse/core'
import type { ColumnType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk'
import type { Cell } from './cellRange'
import { CellRange } from './cellRange'
import { copyTable, message, reactive, ref, unref, useCopy, useEventListener, useI18n } from '#imports'
@ -252,11 +253,20 @@ export function useMultiSelect(
switch (e.keyCode) {
// copy - ctrl/cmd +c
case 67:
// set clipboard context only if single cell selected
if (rowObj.row[columnObj.title!]) {
clipboardContext = {
value: rowObj.row[columnObj.title!],
uidt: columnObj.uidt,
}
} else {
clipboardContext = null
}
await copyValue()
break
case 86:
if (clipboardContext) {
rowObj.row[columnObj.title] = convertCellData({
rowObj.row[columnObj.title!] = convertCellData({
value: clipboardContext.value,
from: clipboardContext.uidt,
to: columnObj.uidt,

Loading…
Cancel
Save