SitePen / dgrid

A lightweight, mobile-ready, data-driven, modular grid widget designed for use with dstore
http://dgrid.io/
Other
628 stars 295 forks source link

Home/end keys don't work with OnDemand grid #1278

Closed zub2 closed 8 years ago

zub2 commented 8 years ago

Pressing home or end keys in an OnDemandGrid does not always scroll to and select the first or the last item.

I'm seeing this with DGrid 1.0.0, both with Chrome 50.0.2661.86 (64-bit) and with Firefox 45.0.2. I suspect this is some sort of a timing issue as the behavior seems worse when the computer is more busy (higher CPU load).

It can be seen in the first testcase in dgrid/test/OnDemand.html ("Simple test to show setting a new store and query to dgrid"). It happens more often if the number of generated data rows is increased (change "rows" from 100 to 1000 in dgrid/test/data/genericData.js).

To reproduce:

Repeat the home/end presses a few times. Sometimes they work OK but especially with increased number of items, often they end up selecting the wrong row. With 1000 items it's almost always wrong. With 100 items it's almost always correct.

It sometimes happens that the grid loses focus completely and home/end starts scrolling the whole page.

kfranqueiro commented 8 years ago

Thanks for pointing this out. This is something I thought I'd fixed over 3 years ago in 9d5627134a48bf6f64939d389b9b38da36f9a1a1, but I can reproduce what you're describing also in performance.html, even against version 0.3.12 which was the first where this fix was present.

I suspect that multiple renderArray calls are actually happening, and so the single-use aspect that Keyboard.js sets up in moveFocusEnd fires too soon.

zub2 commented 8 years ago

In my experiments with implementing of #1279 I used an aspect after _processScroll. It seems to return a promise which is resolved when the rendering is finished. ... Though I'm not sure it covers everything that is rendered.

zub2 commented 8 years ago

... nope, that does not work.