TrimRows plugin not playing nicely with row_above/row_below context menu actions

Tags: #<Tag:0x00007f8b19f4c918>

Hello,

We are using Hansontable quite intensively and are currently facing an issue.

Basically when at least one row is trimmed using TrimRows plugin and then inserting rows using context menu actions row_above/row_below is inserting rows with wrong physical indexes.

Please have a look at this JSFiddle: https://jsfiddle.net/t413Lubn/4/ and do the following actions:

  1. Right click row number 2
  2. Click on context menu action “Trim Row”
  3. Right click row number 4
  4. Click on context menu action “Insert row below”. Everything still looks correct.
  5. Right click row number 6
  6. Click on context menu action “Trim Row”. There we expect that the newly inserted row would be the last one but it’s not. It jumped one row above.

I also saved another version of the JSFiddle: https://jsfiddle.net/t413Lubn/5/ where I provide my own callback for row_above/row_below.
There I use alter method with action insert_row using the physical index (hot.toPhysicalRow) of the row.
But even there the result is not as expected.

Not 100% sure but I have the impression it’s linked to this issue: https://github.com/handsontable/handsontable/issues/5112.
But it would be nice if there is already have a way to fix our problem before the above issue is fixed (I’m open to a dirty/manual solution that would work).

This sounds exactly like wrong index mapping @arnaud.guti1
We’re currently developing a comprehensive index mapping logic for Handsontable that will help us to keep the correct indexes across the plugins.

You can find the topic here https://github.com/handsontable/handsontable/issues/5751
It also mentiones trimRows a couple of times, with rewriting included.

Hi @aleksandra_budnik,

Thanks for the answer/confirmation.

I found a dirty solution for the time being: https://jsfiddle.net/t413Lubn/6/

Basically I added the beforeCreateRow and afterCreateRow hooks.
Before inserting a new row I’m disabling trimRows plugin and saving all the rows that were trimmed in a variable.
Then after the new row is inserted I’m enabling back the plugin and trim back the rows that were initially trimmed.

That’s a great way to workaround this issue. I will let you know as soon as we push the official fix online.

Hi @aleksandra_budnik,
Thanks a lot for all the information.
Do you think it has a chance of being released this year?

The #5751 is planned for October

Hi @arnaud.guti1

The #5751 was introduced in 8.0.0.-beta1 yesterday

Below are the resources

</style><script src="https://cdn.jsdelivr.net/gh/handsontable/handsontable@release/8.0.0-beta.1/dist/handsontable.full.js"></script><link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/gh/handsontable/handsontable@release/8.0.0-beta.1/dist/handsontable.full.css">

And this is how you can download the beta from NPM

npm i handsontable@beta

I appreciate any feedback. Thank you.

Hi @aleksandra_budnik,

Thanks a lot for the good news, we’ll try this beta version soon.

Thanks.

Hi @aleksandra_budnik,

Just to let you know that so far it works great!

We could remove the workarounds from our code.

That’s awesome!

How do you like our v8.0.0 beta release? If you have any feedback share, please let us know

Hi @wojciech.czerniak,

All good for the time being. I’m really happy with all the fixes on indexing between core & the plugins.

Just still one important thing could be enhanced with handsontable :slight_smile: it’s the visibility/density of data in the table.

RowHeights minimum is 23 and that’s still too much for us :slight_smile:

Appart from that small issue the library is really good!

Hey @arnaud.guti1

thank you for the update and feedback :slight_smile: