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

Double load of the first page of a PageableList #538

Closed
harbalk opened this issue Mar 30, 2015 · 3 comments
Closed

Double load of the first page of a PageableList #538

harbalk opened this issue Mar 30, 2015 · 3 comments

Comments

@harbalk
Copy link
Contributor

harbalk commented Mar 30, 2015

The modification of CustomElement attachedCallback function in this commit ibm-js/delite@b3638c5 lead to a problem of double load of the first page of a list.
It is due to a double pass in the if of "initial loading" in the computeProperties function of PageableList.
There is, first, a modification of the store attribute and then a modification of the _collection attribute.

computeProperties: function (props) {
        if (this.pageLength > 0 && this.attached) {
          if ("store" in props || "query" in props || "_collection" in props)  {
                    // Initial loading of the list
                    ...

In the previous version, the store was in the props list before the attached attribute was set at true. Also the only time we passed in the "initial loading if" was when the _collection was modified.

But in this version the store is in the props list at the same as this.attached attribute. There is then one pass because the store has been modified and another because of the _collection, and the page is loaded twice.

There are two solutions of this problem :

  • The first is to set the attached attribute of the CustomElement in the attachedCallback.after(), as it was done in the previous version.
  • The second one is to remove the modification of the store attribute of the list of the conditions of initial loading (remove "store" in props condition). At first seen, I think there is kind of redundancy with _collection modification.

I don't think I have enough knowledge of the code to be able to properly grasp all the impact of this modifications.
Tell me what you think about it.

@cjolif
Copy link
Contributor

cjolif commented Mar 30, 2015

cc: @wkeese it is strange that attached is now set before attachment?

@wkeese
Copy link
Member

wkeese commented Mar 30, 2015

The first is to set the attached attribute of the CustomElement in the attachedCallback.after(), as it was done in the previous version.

I think the reason attached is currently set early is so whenhas("inherited-dir") is true, Bidi#getInheritedDir() will call getComputedStyle() upon page attach.

But I think setting attached later makes sense, especially given the API documentation:

/**
 * Set to true when `attachedCallback()` has completed, and false when `detachedCallback()` called.
 * @member {boolean}
 * @protected
 */
attached: false,

So I'll make that change.

The second one is to remove the modification of the store attribute of the list of the conditions of initial loading (remove "store" in props condition). At first seen, I think there is kind of redundancy with _collection modification.

Perhaps that also makes sense, but I'll do the first change for now.

@wkeese
Copy link
Member

wkeese commented Mar 31, 2015

PS: Thanks for tracking this down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants