ce icon indicating copy to clipboard operation
ce copied to clipboard

Row Add + Column Delete + Undo/Redo Breaks Row

Open john-pavlat opened this issue 1 year ago • 0 comments

I found an issue that can remove cell

elements or throw values in a new row into disarray.

Steps to reproduce:

  1. Go to an instance of jSpreadsheet CE: https://bossanova.uk/jspreadsheet/v4/#spreadsheet (any will do, but it's easiest to see here).
  2. Right-click in row 1, then select "Insert a new row after."
  3. Right-click column C, "Available," then select "Delete selected columns."
  4. With a cell in row 1 selected (to ensure keyboard shortcuts work) press Ctrl+Z twice, undoing both the column deletion and the row addition.
  5. Press Ctrl+Y twice.
  6. Press Ctrl+Z once. If your experience matches mine, the rightmost cell will lack borders and cannot be clicked; upon inspecting the HTML, the element itself is missing.
  7. If you press Ctrl+Z a second time and then repeat steps 4-5 enough, more of these cells will be missing until all cells to the right of the "Available" column will be replaced with blank space. Once the "Available" column is reached and its cell would normally be blanked out, an error stating that a value like obj.records[f][c] or obj.records[l][r] is undefined:
  8. image

    obj.records[l][r] appears to refer to this line in the minified code: for (r = o; r < n + o; r++) obj.records[l][r].parentNode.removeChild(obj.records[l][r]); in the latest non-minified code, it appears to be at line 6644:

    for (var i = columnIndex; i < (numOfColumns + columnIndex); i++) {
            obj.records[j][i].parentNode.removeChild(obj.records[j][i]);
    }
    

    In between steps 2 and 3, one can also set the color value at the right of the column, and then simply press Ctrl+Z three times (undoing delete column, color update, & add row) and Ctrl+Y two times; in this case, the color will not reappear, but an error will be logged: obj.records[t][e] is undefined. The

    still exists, curiously, and one can still double click it to type a hexadecimal code, but it is definitely not showing as intended.

    I repeated the experiment in the above paragraph, but with editing the "Available" and "Price" fields and deleting the "Make" column. Undoing all changes and then redoing the row insert and edits, those two values have apparently shifted over to the cell to the right of where they should be, as though they are thrown off by the affected column.

    Thanks for all your work!

john-pavlat avatar Oct 05 '23 16:10 john-pavlat