Skip to content

Commit 00cbf5c

Browse files
authored
fix: insert column/row buttons not working (#39)
* fix: insert column/row buttons not working * chore: bundle * fix: when inserting columns/rows, the columns/rows number should be increased * chore: bundle * fix: document fix * chore: bump version Co-authored-by: Johnny Almonte <[email protected]>
1 parent a9742da commit 00cbf5c

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

app/components/Home.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default class Home extends React.Component {
1212

1313
this.numRows = 75;
1414
this.numColumns = 26;
15+
this.sheetSizeUpdated = false;
1516
}
1617

1718
componentDidMount() {
@@ -49,16 +50,27 @@ export default class Home extends React.Component {
4950
hideRow: this.onChange,
5051
deleteColumn: this.onChange,
5152
deleteRow: this.onChange,
52-
insertColumn: () => {
53-
var workbook = this.getJSON();
54-
workbook.columns = ++this.numColumns;
55-
this.getSpreadsheet().fromJSON(workbook);
53+
insertColumn: (event) => {
54+
this.numColumns++;
55+
this.sheetSizeUpdated = true;
5656
this.onChange();
5757
},
5858
insertRow: (event) => {
59-
var workbook = this.getJSON();
60-
workbook.rows = ++this.numRows;
61-
this.getSpreadsheet().fromJSON(workbook);
59+
this.numRows++;
60+
this.sheetSizeUpdated = true;
61+
this.onChange();
62+
},
63+
render: () => {
64+
if (!this.sheetSizeUpdated) {
65+
return;
66+
}
67+
/**
68+
* To update the sheet size when a new column/row is inserted, we need to:
69+
* 1. Rebuild the spreadsheet with the current data
70+
* 2. Immediately save the note
71+
*/
72+
this.sheetSizeUpdated = false;
73+
this.getSpreadsheet().fromJSON(this.getJSON());
6274
this.onChange();
6375
}
6476
});

app/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@
2121
<body>
2222
<script type="text/javascript" src="dist.js"></script>
2323
<div id="spreadsheet"></div>
24-
</script>
2524
</body>
2625
</html>

dist/dist.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sn-spreadsheets",
3-
"version": "1.3.6",
3+
"version": "1.3.7",
44
"main": "dist/dist.js",
55
"scripts": {
66
"lint": "eslint --cache --ignore-path .gitignore --ext .jsx,.js --format=node_modules/eslint-formatter-pretty .",

0 commit comments

Comments
 (0)