Skip to content

Commit

Permalink
fix(Grid.js): checking if selection valid before calling functions (w…
Browse files Browse the repository at this point in the history
…hich may return NaN if selectio
  • Loading branch information
pdudhat committed Jun 10, 2020
1 parent 161703b commit 7aeb47c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
29 changes: 15 additions & 14 deletions src/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,20 +753,21 @@ class Grid extends React.PureComponent {
// })
this.edit(rowIndex, columnIndex)
}
}
if (!this.isGridEditing()) {
if (e.keyCode === 37) this.selectLeft(e.shiftKey)
if (e.keyCode === 39) this.selectRight(e.shiftKey)
if (e.keyCode === 38) this.selectTop(e.shiftKey)
if (e.keyCode === 40) this.selectBottom(e.shiftKey)
if (e.ctrlKey && e.keyCode === 65) this.selectAll()
if (e.keyCode === 9) {
e.preventDefault()
e.shiftKey ? this.selectLeft() : this.selectRight()
}
if (e.keyCode === 46) {
e.preventDefault()
this.deleteSelection()

if (!this.isGridEditing()) {
if (e.keyCode === 37) this.selectLeft(e.shiftKey)
if (e.keyCode === 39) this.selectRight(e.shiftKey)
if (e.keyCode === 38) this.selectTop(e.shiftKey)
if (e.keyCode === 40) this.selectBottom(e.shiftKey)
if (e.ctrlKey && e.keyCode === 65) this.selectAll()
if (e.keyCode === 9) {
e.preventDefault()
e.shiftKey ? this.selectLeft() : this.selectRight()
}
if (e.keyCode === 46) {
e.preventDefault()
this.deleteSelection()
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/editEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const generateInitialEditInfo = ({ addedFirst } = {}) => ({
removed: [],
// originalRow => editedRow
updatedMap: new Map(),
// editedRow => orignalRow
// editedRow => originalRow
dirtyMap: new Map(),
history: [],
})
Expand Down

0 comments on commit 7aeb47c

Please sign in to comment.