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

trimRows onBeforeCreateRow callback changes value in hooks that are registered afterwards #5585

Closed
wojciechczerniak opened this Issue Nov 15, 2018 · 0 comments

Comments

Projects
None yet
3 participants
@wojciechczerniak
Copy link
Member

wojciechczerniak commented Nov 15, 2018

Description

TrimRows callback for beforeCreateRow changes the index value because it's always returning new value:

https://github.com/handsontable/handsontable-pro/blob/b58392f155d73261fb8d402abbc579895022a674/src/plugins/trimRows/trimRows.js#L255-L257

Should return false if condition is met and undefined in all other cases so it does not change the index value. I.e.:

onBeforeCreateRow(index, amount, source) {
    if (this.isEnabled() && this.trimmedRows.length > 0 && source === 'auto') {
        return false;
    }
}

With filters/trimrows disabled the correct row index is available in the hook callback.

Steps to reproduce

  1. Enable Filters (or TrimRows?)
  2. Add beforeCreateRow hook
  3. Add new row from Context Menu
  4. Check/log index argument in your callback
  5. Row index is always equal true
this.addHook('beforeRemoveRow', (index, amount) => {
  console.log(index); // === always true
});

Demo

https://jsfiddle.net/wczerniak/rx87492w/

Your environment

  • Handsontable version: 6.2.0
  • Browser Name and version: Firefox
  • Operating System: OS X

@wojciechczerniak wojciechczerniak added this to the February 2019 milestone Jan 28, 2019

@jansiegel jansiegel self-assigned this Feb 11, 2019

jansiegel added a commit that referenced this issue Feb 11, 2019

jansiegel added a commit that referenced this issue Feb 15, 2019

@AMBudnik AMBudnik closed this Mar 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.