Skip to content

Commit

Permalink
Nc fix: disable undo redo if expanded form is open (#8509)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rameshmane7218 committed May 17, 2024
1 parent 042e435 commit f01d99f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
13 changes: 12 additions & 1 deletion packages/nc-gui/components/cell/DatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 ';':
Expand Down
13 changes: 12 additions & 1 deletion packages/nc-gui/components/cell/DateTimePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 ';':
Expand Down
13 changes: 12 additions & 1 deletion packages/nc-gui/components/cell/TimePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 ';':
Expand Down
13 changes: 12 additions & 1 deletion packages/nc-gui/components/cell/YearPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 ';':
Expand Down
2 changes: 1 addition & 1 deletion packages/nc-gui/composables/useUndoRedo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions packages/nc-gui/utils/browserUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down

0 comments on commit f01d99f

Please sign in to comment.