Scroller + stateSave bug / regression

Scroller + stateSave bug / regression

fynnfynn Posts: 2Questions: 1Answers: 0

Hi,
I've noticed a regression when updating from DataTables 1.10.15 + Scroller 1.4.2 to DataTables 1.10.18 + Scroller 2.0.0

Problem: After reloading the page the table is not scrolled to the position it was before reloading.

Working example with old version: http://live.datatables.net/lawowifi/1/edit?html,js,output

Regression in example with newer version: http://live.datatables.net/zemoxidu/1/edit?html,js,output

Identical code is used in both examples:

$('#example').DataTable({
    stateSave: true,
    scrollY:   200,
    scroller:  true    
});

To reproduce: Open the regressed example page, scroll a bit down, click "run with JS" to reload the example. The scroll position resets to the top and info below table may show wrong numbers. If you do the same steps with the older version, scroll position will stay at the right stop after reloading. Be sure to clear you local browser storage before viewing the other example as they share the same storage.

Analysis: I've already found an error in dataTables.scroller.js line 677
this.scrollType should probably be this.s.scrollType
However, changing this line does not solve the problem. I guess this.s.scrollType needs to be set to 'jump' during an initial load of the page.

Many thanks for looking into this!

Best regards,
Fynn

Answers

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    Hi Fynn,

    Many thanks for flagging this up - I agree there is a bug there. It looks like it might only be happening under certain conditions (probably related to the length of the data) as this example shows it working.

    I'll post back when I've had a chance to look into this in more detail.

    Allan

  • fynnfynn Posts: 2Questions: 1Answers: 0

    Hi Allan,

    thank you for taking a look at the issue. I've tested your example and it has a similar problem: Scroll down, then reload the page. The correct data is shown but the scroller position stays at the top.

    Initial scroll down:
    Initial scroll down
    After reload:
    After reload

    Cheers,
    Fynn

  • Jan NěmecJan Němec Posts: 1Questions: 0Answers: 0
    edited May 2019

    Hi fynn,

    I had same problem.

    I did update on row 677 and scroller start initialize on desired position

    iScrollTop = this.s.scrollType === 'jump' ?
    this._domain( 'physicalToVirtual', this.s.topRowFloat * heights.row ) :
    this.s.scrollType === undefined ? this.s.baseScrollTop : iScrollTop;

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    I've just done a similar, albeit slightly different, fix :).

    This will be in the next release of Scroller which should drop before the end of the month.

    Allan

  • Petr N.Petr N. Posts: 1Questions: 0Answers: 0

    Hi, I have the same problem - after state loading scroller does not scroll to correct position. Tested on version 1.10.20 and scroller version 2.0.1
    In mentioned example: https://datatables.net/extensions/scroller/examples/initialisation/state_saving.html
    the bug still exists.

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    Sorry yes - it appears to have frustratingly resurfaced. We've got it logged to address for the next release.

    Allan

  • smohantysmohanty Posts: 14Questions: 3Answers: 0

    Any updates on this?

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    No, sorry, this is still in the backlog (DD-1748 and DD-1486 for my reference). We'll report back when it's progressed.

    Colin

This discussion has been closed.