| 214 | } |
| 215 | |
| 216 | handleKeyboardCellMovement (e, commit = false) { |
| 217 | const {start, editing} = this.getState() |
| 218 | const {data} = this.props |
| 219 | const isEditing = editing && !isEmpty(editing) |
| 220 | const currentCell = data[start.i] && data[start.i][start.j] |
| 221 | |
| 222 | if (isEditing && !commit) { |
| 223 | return false |
| 224 | } |
| 225 | const hasComponent = currentCell && currentCell.component |
| 226 | |
| 227 | const keyCode = e.which || e.keyCode |
| 228 | |
| 229 | if (hasComponent && (isEditing)) { |
| 230 | e.preventDefault() |
| 231 | return |
| 232 | } |
| 233 | |
| 234 | if (keyCode === TAB_KEY) { |
| 235 | this.handleNavigate(e, {i: 0, j: e.shiftKey ? -1 : 1}, true) |
| 236 | } else if (keyCode === RIGHT_KEY) { |
| 237 | this.handleNavigate(e, {i: 0, j: 1}) |
| 238 | } else if (keyCode === LEFT_KEY) { |
| 239 | this.handleNavigate(e, {i: 0, j: -1}) |
| 240 | } else if (keyCode === UP_KEY) { |
| 241 | this.handleNavigate(e, {i: -1, j: 0}) |
| 242 | } else if (keyCode === DOWN_KEY) { |
| 243 | this.handleNavigate(e, {i: 1, j: 0}) |
| 244 | } else if (commit && keyCode === ENTER_KEY) { |
| 245 | this.handleNavigate(e, {i: e.shiftKey ? -1 : 1, j: 0}) |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | handleKey (e) { |
| 250 | if (e.isPropagationStopped && e.isPropagationStopped()) { |