Browse Source

Nc fix: disable undo redo if expanded form is open (#8509)

* fix(nc-gui): disable undo redo if expanded form is open

* fix(nc-gui): date time related picker open in background issue if expanded form is open

* chore(nc-gui): lint
pull/8516/head
Ramesh Mane 6 months ago committed by GitHub
parent
commit
f01d99fe66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      packages/nc-gui/components/cell/DatePicker.vue
  2. 13
      packages/nc-gui/components/cell/DateTimePicker.vue
  3. 13
      packages/nc-gui/components/cell/TimePicker.vue
  4. 13
      packages/nc-gui/components/cell/YearPicker.vue
  5. 2
      packages/nc-gui/composables/useUndoRedo.ts
  6. 1
      packages/nc-gui/utils/browserUtils.ts

13
packages/nc-gui/components/cell/DatePicker.vue

@ -205,7 +205,18 @@ useEventListener(document, 'keydown', (e: KeyboardEvent) => {
// To prevent event listener on non active cell
if (!active.value) return
if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey || !isGrid.value || isExpandedForm.value || isEditColumn.value) return
if (
e.altKey ||
e.ctrlKey ||
e.shiftKey ||
e.metaKey ||
!isGrid.value ||
isExpandedForm.value ||
isEditColumn.value ||
isExpandedFormOpen()
) {
return
}
switch (e.key) {
case ';':

13
packages/nc-gui/components/cell/DateTimePicker.vue

@ -269,7 +269,18 @@ useEventListener(document, 'keydown', (e: KeyboardEvent) => {
// To prevent event listener on non active cell
if (!active.value) return
if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey || !isGrid.value || isExpandedForm.value || isEditColumn.value) return
if (
e.altKey ||
e.ctrlKey ||
e.shiftKey ||
e.metaKey ||
!isGrid.value ||
isExpandedForm.value ||
isEditColumn.value ||
isExpandedFormOpen()
) {
return
}
switch (e.key) {
case ';':

13
packages/nc-gui/components/cell/TimePicker.vue

@ -185,7 +185,18 @@ useEventListener(document, 'keydown', (e: KeyboardEvent) => {
// To prevent event listener on non active cell
if (!active.value) return
if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey || !isGrid.value || isExpandedForm.value || isEditColumn.value) return
if (
e.altKey ||
e.ctrlKey ||
e.shiftKey ||
e.metaKey ||
!isGrid.value ||
isExpandedForm.value ||
isEditColumn.value ||
isExpandedFormOpen()
) {
return
}
switch (e.key) {
case ';':

13
packages/nc-gui/components/cell/YearPicker.vue

@ -176,7 +176,18 @@ useEventListener(document, 'keydown', (e: KeyboardEvent) => {
// To prevent event listener on non active cell
if (!active.value) return
if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey || !isGrid.value || isExpandedForm.value || isEditColumn.value) return
if (
e.altKey ||
e.ctrlKey ||
e.shiftKey ||
e.metaKey ||
!isGrid.value ||
isExpandedForm.value ||
isEditColumn.value ||
isExpandedFormOpen()
) {
return
}
switch (e.key) {
case ';':

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

@ -167,7 +167,7 @@ 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 ((e && (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement)) || isExpandedFormOpen()) return
if (cmdOrCtrl && !e.altKey) {
switch (e.keyCode) {

1
packages/nc-gui/utils/browserUtils.ts

@ -2,6 +2,7 @@
export const isMac = () => /Mac/i.test(navigator.platform)
export const isDrawerExist = () => document.querySelector('.ant-drawer-open')
export const isDrawerOrModalExist = () => document.querySelector('.ant-modal.active, .ant-drawer-open')
export const isExpandedFormOpen = () => document.querySelector('.nc-drawer-expanded-form.active')
export const isExpandedCellInputExist = () => document.querySelector('.expanded-cell-input')
export const cmdKActive = () => document.querySelector('.cmdk-modal-active')

Loading…
Cancel
Save