Handsontable: [Bug] Object data source keys can't have name of Array function.

Created on 14 Mar 2017  ·  3Comments  ·  Source: handsontable/handsontable

Description


If you have an object data source with one of the keys of the object as the name of an Array function, such as 'shift', a JavaScript error is raised and that cell is permanently in edit mode.

From a small amount of debugging, I found that one cause is dataMap.js:137

typeof this.colToPropCache[col] !== 'undefined'

this.colToPropCache is an Array, and when you click away from a cell, this function is called with col as 'shift'.
So, due to JavaScript, this.colToPropCache['shift'] gives the function this.colToPropCache.shift, which does not have the type of undefined, so it returns Array.prototype.shift.

Steps to reproduce

  1. Create a Handsontable with an object data-source, and one of the keys of the object as 'shift' or another Array function.
  2. Double click on a cell in that column to edit it
  3. Click on a different cell

Demo


http://jsfiddle.net/p5c9vzwg/
Double click on a cell in the first column, then click on any other cell

Your environment

  • Handsontable version: Current develop branch
  • Browser Name and version: Chrome 55.0
  • Operating System: Ubuntu
Bug

All 3 comments

Thanks for sharing @lewisjb
You are right when we change the shift to anything else then we are able to exit the cell.

bug

I think this might have been fixed somewhere along the way. @AMBudnik @aninde

✅ v7.1.1: https://jsfiddle.net/1rzc5xe9/
✅ v.0.32.0: https://jsfiddle.net/m2jk4ftw/
❌ v0.31.1: https://jsfiddle.net/6gx8kv94/

Agree @wojciechczerniak

it works well now and doesn't break in 8.0.0-rc1 so I guess that we can close the issue.

Was this page helpful?
0 / 5 - 0 ratings