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. 8
      packages/nc-gui/components/cell/SingleSelect.vue
  3. 14
      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
}

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

@ -59,7 +59,7 @@ const options = computed<(SelectOptionType & { value: string })[]>(() => {
if (column?.value.colOptions) {
const opts = column.value.colOptions
? // todo: fix colOptions type, options does not exist as a property
(column.value.colOptions as any).options.filter((el: SelectOptionType) => el.title !== '') || []
(column.value.colOptions as any).options.filter((el: SelectOptionType) => el.title !== '') || []
: []
for (const op of opts.filter((el: any) => el.order === null)) {
op.title = op.title.replace(/^'/, '').replace(/'$/, '')
@ -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))
}

14
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,17 +253,26 @@ 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,
})
e.preventDefault()
makeEditable(rowObj,columnObj)
makeEditable(rowObj, columnObj)
} else {
clearCell(selectedCell as { row: number; col: number }, true)
makeEditable(rowObj, columnObj)

Loading…
Cancel
Save