Browse Source

fix: block default action on shortcut key press and typo correction

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4222/head
Pranav C 2 years ago
parent
commit
72d10d415e
  1. 8
      packages/nc-gui/components/smartsheet/Grid.vue
  2. 5
      packages/nc-gui/components/virtual-cell/components/ListItems.vue

8
packages/nc-gui/components/smartsheet/Grid.vue

@ -177,11 +177,15 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange
const activePickerOrDropdownEl = document.querySelector( const activePickerOrDropdownEl = document.querySelector(
'.nc-picker-datetime.active,.nc-dropdown-single-select-cell.active,.nc-dropdown-multi-select-cell.active,.nc-picker-date.active,.nc-picker-year.active,.nc-picker-time.active', '.nc-picker-datetime.active,.nc-dropdown-single-select-cell.active,.nc-dropdown-multi-select-cell.active,.nc-picker-date.active,.nc-picker-year.active,.nc-picker-time.active',
) )
if (activePickerOrDropdownEl) return true if (activePickerOrDropdownEl) {
e.preventDefault()
return true
}
const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey
if (e.key === 'Space') { if (e.code === 'Space') {
if (selected.row !== null && !editEnabled) { if (selected.row !== null && !editEnabled) {
e.preventDefault()
const row = data.value[selected.row] const row = data.value[selected.row]
expandForm(row) expandForm(row)
return true return true

5
packages/nc-gui/components/virtual-cell/components/ListItems.vue

@ -108,10 +108,12 @@ useSelectedCellKeyupListener(vModel, (e: KeyboardEvent) => {
switch (e.key) { switch (e.key) {
case 'ArrowLeft': case 'ArrowLeft':
e.stopPropagation() e.stopPropagation()
e.preventDefault()
if (childrenExcludedListPagination.page > 1) childrenExcludedListPagination.page-- if (childrenExcludedListPagination.page > 1) childrenExcludedListPagination.page--
break break
case 'ArrowRight': case 'ArrowRight':
e.stopPropagation() e.stopPropagation()
e.preventDefault()
if ( if (
childrenExcludedList.value?.pageInfo && childrenExcludedList.value?.pageInfo &&
childrenExcludedListPagination.page < childrenExcludedListPagination.page <
@ -122,10 +124,12 @@ useSelectedCellKeyupListener(vModel, (e: KeyboardEvent) => {
case 'ArrowUp': case 'ArrowUp':
selectedRowIndex.value = Math.max(0, selectedRowIndex.value - 1) selectedRowIndex.value = Math.max(0, selectedRowIndex.value - 1)
e.stopPropagation() e.stopPropagation()
e.preventDefault()
break break
case 'ArrowDown': case 'ArrowDown':
selectedRowIndex.value = Math.min(childrenExcludedList.value?.list?.length - 1, selectedRowIndex.value + 1) selectedRowIndex.value = Math.min(childrenExcludedList.value?.list?.length - 1, selectedRowIndex.value + 1)
e.stopPropagation() e.stopPropagation()
e.preventDefault()
break break
case 'Enter': case 'Enter':
{ {
@ -133,6 +137,7 @@ useSelectedCellKeyupListener(vModel, (e: KeyboardEvent) => {
if (selectedRow) { if (selectedRow) {
linkRow(selectedRow) linkRow(selectedRow)
e.stopPropagation() e.stopPropagation()
e.preventDefault()
} }
} }
break break

Loading…
Cancel
Save