From 1fa5e3c251b9f7a55d3d27bb3d3e5d0d90a59ef4 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 3 Nov 2022 16:49:56 +0530 Subject: [PATCH] fix: on escape key press toggle to readonly Signed-off-by: Pranav C --- packages/nc-gui/components/smartsheet/Grid.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index 99b86bcdf2..e02d7c49e1 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -156,13 +156,12 @@ const getContainerScrollForElement = ( relativePos.bottom + (offset?.bottom || 0) > 0 ? container.scrollTop + relativePos.bottom + (offset?.bottom || 0) : relativePos.top - (offset?.top || 0) < 0 - ? container.scrollTop + relativePos.top - (offset?.top || 0) - : container.scrollTop + ? container.scrollTop + relativePos.top - (offset?.top || 0) + : container.scrollTop return scroll } - const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange, selected } = useMultiSelect( fields, data, @@ -183,13 +182,18 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange } const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey - if (e.code === 'Space') { + if (e.key === ' ') { if (selected.row !== null && !editEnabled) { e.preventDefault() const row = data.value[selected.row] expandForm(row) return true } + } else if (e.key === 'Escape') { + if (editEnabled) { + editEnabled = false + return true + } } if (cmdOrCtrl) { switch (e.key) {