Browse Source

feat: on adding new ow scroll to new cell and make first cell active

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5805/head
Pranav C 2 years ago
parent
commit
9679a6691f
  1. 12
      packages/nc-gui/components/smartsheet/Grid.vue
  2. 1
      packages/nc-gui/composables/useMultiSelect/index.ts

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

@ -117,7 +117,7 @@ const {
formattedData: data, formattedData: data,
updateOrSaveRow, updateOrSaveRow,
changePage, changePage,
addEmptyRow, addEmptyRow: _addEmptyRow,
deleteRow, deleteRow,
deleteSelectedRows, deleteSelectedRows,
selectedAllRecords, selectedAllRecords,
@ -200,6 +200,7 @@ const {
isCellActive, isCellActive,
tbodyEl, tbodyEl,
resetSelectedRange, resetSelectedRange,
makeActive,
selectedRange, selectedRange,
} = useMultiSelect( } = useMultiSelect(
meta, meta,
@ -804,6 +805,14 @@ const deleteSelectedRangeOfRows = () => {
activeCell.col = null activeCell.col = null
}) })
} }
function addEmptyRow(row?: number) {
_addEmptyRow(row)
nextTick().then(() => {
makeActive(row ?? data.value.length - 1, 0)
scrollToCell?.()
})
}
</script> </script>
<template> <template>
@ -1009,6 +1018,7 @@ const deleteSelectedRangeOfRows = () => {
v-e="['c:row:add:grid-bottom']" v-e="['c:row:add:grid-bottom']"
:colspan="visibleColLength + 1" :colspan="visibleColLength + 1"
class="text-left pointer nc-grid-add-new-cell cursor-pointer" class="text-left pointer nc-grid-add-new-cell cursor-pointer"
@mouseup.stop
@click="addEmptyRow()" @click="addEmptyRow()"
> >
<div class="px-2 w-full flex items-center text-gray-500"> <div class="px-2 w-full flex items-center text-gray-500">

1
packages/nc-gui/composables/useMultiSelect/index.ts

@ -446,5 +446,6 @@ export function useMultiSelect(
tbodyEl, tbodyEl,
resetSelectedRange, resetSelectedRange,
selectedRange, selectedRange,
makeActive,
} }
} }

Loading…
Cancel
Save