-
Notifications
You must be signed in to change notification settings - Fork 353
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
RowMeta index becomes stale when a row is prepended #609
Comments
The best way to solve this will be making Does that make sense? |
Thanks for the direction. I'm working from this failing test. My initial thought is to compute and set the row meta's relative offset as part of the To confirm, this comment refers to it as a "perceived index." This means the meta index should not take into account collapsed nodes, right? |
Actually I meant the opposite 😅perceived index meaning what we actually end up seeing rendered as the n-th row. So, given a particular collapse state in the tree, it flattens to real rows with a real index. The idea is that once we index into the tree (with its collapse state) it's basically an array, and everywhere else we treat it as if it were an array. If we ignored collapse state, it could throw calculations off quite a bit I think |
After mulling it over a bit, here is what I've come up with. Some pseudo code for calculating offsets and index: Prev offset:
Calculate index from a while (this.prev) { someNumber += this.prevOffset } We should be able to get that final offset (and index) of a row by adding the Unfortunately, it seems that in order to get the necessary context we need to access the nodes directly which may be costly. Is there a more ideal way to get the offset information? Maybe this approach can be simplified by adding a computed to the node itself. Does that sound right? /cc @rondale-sc |
Thanks for all the great work on this -- abstracting flexible tables ain't easy.
Currently, the
rowMeta.index
property is only updated whenever a node is accessed.This seems sufficient for most cases. However, it doesn't cover scenarios where a row is prepended (or, actually, any non-append operation). Because it shifts the indexes for subsequent rows with no change to the row objects. So there is usually no need to retrieve the row.
My specific use case is rendering row numbers from
rowMeta.index
. The workaround is to force object retrieval by binding torows.length
and re-rendering the relevant template section.On Friday, I'm hoping to look into this a bit more and possibly come up with a solution. So any direction you can give would be much appreciated.
The text was updated successfully, but these errors were encountered: