Browse Source

Merge pull request #6835 from nocodb/fix/6371-undo

fix: stop undo actions on event for inputs
pull/6838/head
mertmit 11 months ago committed by GitHub
parent
commit
5a13765649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/nc-gui/components/cell/Currency.vue
  2. 2
      packages/nc-gui/components/cell/Decimal.vue
  3. 2
      packages/nc-gui/components/cell/Duration.vue
  4. 2
      packages/nc-gui/components/cell/Email.vue
  5. 2
      packages/nc-gui/components/cell/Float.vue
  6. 2
      packages/nc-gui/components/cell/Percent.vue
  7. 2
      packages/nc-gui/components/cell/PhoneNumber.vue
  8. 2
      packages/nc-gui/components/cell/Text.vue
  9. 2
      packages/nc-gui/components/cell/TextArea.vue
  10. 2
      packages/nc-gui/components/cell/Url.vue
  11. 13
      packages/nc-gui/composables/useUndoRedo.ts

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

@ -86,8 +86,6 @@ onMounted(() => {
@keydown.right.stop
@keydown.up.stop
@keydown.delete.stop
@keydown.ctrl.z.stop
@keydown.meta.z.stop
@selectstart.capture.stop
@mousedown.stop
@contextmenu.stop

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

@ -105,8 +105,6 @@ watch(isExpandedFormOpen, () => {
@keydown.right.stop
@keydown.up.stop="onKeyDown"
@keydown.delete.stop
@keydown.ctrl.z.stop
@keydown.meta.z.stop
@selectstart.capture.stop
@mousedown.stop
/>

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

@ -103,8 +103,6 @@ const focus: VNodeRef = (el) => !isExpandedFormOpen.value && !isEditColumn.value
@keydown.right.stop
@keydown.up.stop
@keydown.delete.stop
@keydown.ctrl.z.stop
@keydown.meta.z.stop
@selectstart.capture.stop
@mousedown.stop
/>

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

@ -78,8 +78,6 @@ watch(
@keydown.right.stop
@keydown.up.stop
@keydown.delete.stop
@keydown.ctrl.z.stop
@keydown.meta.z.stop
@selectstart.capture.stop
@mousedown.stop
/>

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

@ -58,8 +58,6 @@ const focus: VNodeRef = (el) => !isExpandedFormOpen.value && !isEditColumn.value
@keydown.right.stop
@keydown.up.stop
@keydown.delete.stop
@keydown.ctrl.z.stop
@keydown.meta.z.stop
@selectstart.capture.stop
@mousedown.stop
/>

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

@ -49,8 +49,6 @@ const focus: VNodeRef = (el) => !isExpandedFormOpen.value && !isEditColumn.value
@keydown.right.stop
@keydown.up.stop
@keydown.delete.stop
@keydown.ctrl.z.stop
@keydown.meta.z.stop
@selectstart.capture.stop
@mousedown.stop
/>

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

@ -70,8 +70,6 @@ watch(
@keydown.right.stop
@keydown.up.stop
@keydown.delete.stop
@keydown.ctrl.z.stop
@keydown.meta.z.stop
@selectstart.capture.stop
@mousedown.stop
/>

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

@ -43,8 +43,6 @@ const focus: VNodeRef = (el) => !isExpandedFormOpen.value && !isEditColumn.value
@keydown.right.stop
@keydown.up.stop
@keydown.delete.stop
@keydown.ctrl.z.stop
@keydown.meta.z.stop
@selectstart.capture.stop
@mousedown.stop
/>

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

@ -100,8 +100,6 @@ onClickOutside(inputWrapperRef, (e) => {
@keydown.right.stop
@keydown.up.stop
@keydown.delete.stop
@keydown.ctrl.z.stop
@keydown.meta.z.stop
@selectstart.capture.stop
@mousedown.stop
/>

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

@ -99,8 +99,6 @@ watch(
@keydown.right.stop
@keydown.up.stop
@keydown.delete.stop
@keydown.ctrl.z.stop
@keydown.meta.z.stop
@selectstart.capture.stop
@mousedown.stop
/>

13
packages/nc-gui/composables/useUndoRedo.ts

@ -26,6 +26,16 @@ export const useUndoRedo = createSharedComposable(() => {
})
const isSameScope = (sc: { key: string; param: string | string[] }[]) => {
// TODO - improve this logic
// for now we disable undo/redo for webhook, field, api, relation
const slugs = scope.value.find((s) => s.key === 'slugs')
if (slugs) {
const params = Array.isArray(slugs.param) ? slugs.param : slugs.param.split(',')
if (params.some((el) => ['webhook', 'field', 'api', 'relation'].includes(el))) {
return false
}
}
return sc.every((s) => {
return scope.value.some(
// viewTitle is optional for default view
@ -158,6 +168,9 @@ export const useUndoRedo = createSharedComposable(() => {
useEventListener(document, 'keydown', async (e: KeyboardEvent) => {
const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey
if (e && (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement)) return
if (cmdOrCtrl && !e.altKey) {
switch (e.keyCode) {
case 90: {

Loading…
Cancel
Save