react-datasheet-grid icon indicating copy to clipboard operation
react-datasheet-grid copied to clipboard

Add multiple rows causes blank space at the top of table

Open nick-keller opened this issue 3 years ago • 2 comments
trafficstars

Discussed in https://github.com/Equify/react-datasheet-grid/discussions/144

Originally posted by Richard-97 April 5, 2022 Hey,

I have a problem with adding multiple rows. There is blank space at the top of the table. The same problem is happing int he demo at home page (added video). The problem is when you select more than 4 rows.

Could you please look on this problem? Thank you.

https://user-images.githubusercontent.com/42608419/161763345-daebffa6-9cb8-4d0b-bc35-9655c71cde4d.mov

nick-keller avatar Apr 21 '22 16:04 nick-keller

It happen at onChange function

if (operation.type === 'CREATE') {
    const count = operation.toRowIndex - operation.fromRowIndex
    const addedRows = rows.slice(operation.fromRowIndex, operation.toRowIndex)
    if (!operation.fromRowIndex) {
      setRows([
        ...addedRows,
        ...rawRows.slice(operation.fromRowIndex),
      ])
      return
    }
   setRows([
      ...rawRows.slice(0, operation.fromRowIndex),
      ...addedRows,
      ...rawRows.slice(operation.fromRowIndex), 
   ])
}

superchow avatar Apr 28 '22 06:04 superchow

Works fine for me.

Macbook: Firefox, Chrome

otariterterashvili avatar Apr 12 '23 08:04 otariterterashvili