Browse Source

fix(gui): skip unsaved records while switching between rows

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5184/head
Pranav C 2 years ago
parent
commit
f392ebdff7
  1. 2
      packages/nc-gui/components/smartsheet/Grid.vue
  2. 5
      packages/nc-gui/composables/useViewData.ts

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

@ -982,7 +982,7 @@ const closeAddColumnDropdown = () => {
:view="view"
show-next-prev-icons
:first-row="getExpandedRowIndex() === 0"
:last-row="getExpandedRowIndex() === paginationData.totalRows - 1"
:last-row="getExpandedRowIndex() === data.length - 1"
@next="navigateToSiblingRow(NavigateDir.NEXT)"
@prev="navigateToSiblingRow(NavigateDir.PREV)"
/>

5
packages/nc-gui/composables/useViewData.ts

@ -490,6 +490,11 @@ export function useViewData(
// calculate next row index based on direction
let siblingRowIndex = expandedRowIndex + (dir === NavigateDir.NEXT ? 1 : -1)
// if unsaved row skip it
while (formattedData.value[siblingRowIndex]?.rowMeta?.new) {
siblingRowIndex = siblingRowIndex + (dir === NavigateDir.NEXT ? 1 : -1)
}
const currentPage = paginationData?.value?.page || 1
// if next row index is less than 0, go to previous page and point to last element

Loading…
Cancel
Save