Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new test to showcase onChange bug when triggered via 'edit' #284

Merged
merged 1 commit into from
Mar 8, 2013

Conversation

thanpolas
Copy link
Contributor

There is a bug and an inconsistency on the data object that is passed as parameter on the callback of the onChange event.

I have written this test to illustrate the issues. It is triggered when changing the contents of the table via the setDataAtCell method, which results in triggering an onChange event with the sourceType of edit.

The _bug_ is that no previous value is defined, the array index 2 should contain the previous value of the cell before it was changed. The value of that index is undefined, which apparently is a bug.

The _inconsistency_ is on the col field, or array index 1. When the event is triggered with the setDataAtCell method (source type) the value of the col is its numeric representation.

When the event is triggered by the user editing on the table (source populateFromArray) then the col has the value that was defined in the data as key.

e.g.

var sampleData = [{
  col1: 'a',
  col2: 'b',
  col3: 'c'
}];

$container.handsontable({
  data: sampleData,
  onChange: function (e, source) {
    // Assume we edit Row 0, Col 0
    //
    // When source == edit, then:
    e.shift() == [0, 0, undefined, 'test'];

    // when source == populateFromArray
    e.shift() == [0, 'col1', 'a', 'test'];        
  }
});

warpech added a commit that referenced this pull request Mar 8, 2013
…ods `setDataAtRowProp` and `getDataAtRowProp` (#284)
@warpech warpech merged commit 88459f3 into handsontable:master Mar 8, 2013
@warpech
Copy link
Member

warpech commented Mar 8, 2013

Sorry for long wait, finally I put myself together to merge your pull request and fix this. Fixed from version 0.8.11

See the release notes for 0.8.11 for more information about the implications.

@thanpolas
Copy link
Contributor Author

Never too late :) thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants