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

Stored "currentPage" offset can cause admin UI list view to display nothing #2063

Closed
dacre-denny opened this issue Dec 8, 2019 · 4 comments · Fixed by #2087
Closed

Stored "currentPage" offset can cause admin UI list view to display nothing #2063

dacre-denny opened this issue Dec 8, 2019 · 4 comments · Fixed by #2087

Comments

@dacre-denny
Copy link

Bug report

Describe the bug

Keystone's admin UI remembers the last "currentPage" offset that the user navigated for a particular list (via the admin UI's pagination controls). This can cause problems when enough items are removed from a list such that the remembered "currentPage" is offset beyond the remaining number of items in that list. In such situations, the admin UI incorrectly show the "No items to display yet.." message for the list view, even though there is still data present in that list.

To Reproduce

Steps to reproduce the behaviour:

1.Populate a list Foo with a few hundred items of data
2. View the Foo list in the admin ui, and navigate to the final page of data for the list via the pagination controls
3. Execute a mutation, and delete half the items in the Foo list
4. Reload the admin ui, and navigate to Foo in the admin ui
5. The admin ui shows message "No foos to display yet..", even though there is still data in this list.

Expected behaviour

1.Populate a list Foo with a few hundred items of data
2. View the Foo list in the admin ui, and navigate to the final page of data for the list via the pagination controls
3. Execute a mutation, and delete half the items in the Foo list
4. Reload the admin ui, and navigate to Foo in the admin ui
5. The admin ui should, by default, show the data that still exists in the Foo list. My preference would be for the admin ui to "self correct" the "currentPage" offset back to "0" in the case that it's "remembered" offset exceeded the total count of items in the list.

@dacre-denny dacre-denny changed the title Stored "currentPage" offset can cause List view to show nothing Stored "currentPage" offset can cause admin UI list view to display nothing Dec 8, 2019
@Vultraz
Copy link
Contributor

Vultraz commented Dec 8, 2019

An even simpler way to reproduce this is to create a batch of items and set defaultPageSize to a low number (1 or 2). Navigate to some page, then remove defaultPageSize and restart the server. When trying to view the list in the Admin UI again you will end up with the behavior described above.

@dacre-denny
Copy link
Author

I'm new to Keystone - how is defaultPageSize set?

@Vultraz
Copy link
Contributor

Vultraz commented Dec 8, 2019

keystone.createList('SelectTest', {
  fields: {
    options: {
      type: Select,
      options: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'],
    },
  },
  adminConfig: {
    defaultPageSize: 2,
  },
});

@MadeByMike
Copy link
Contributor

Another way to repoduce this is to add ?currentPage=999999 to the end of the list page URL. (Unless you have more than 49999950 items)

I'd say this is not a bug but expected behaviour in most cases. We could attempt to detect when the current page is beyond the length of the list given the page length but this get tricky because with permissions on items we might not know exactly how many items the user can see.

The only other way I can think to 'solve' this is before rendering 'No ___s to display' we make sure the page is set to 0.

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

Successfully merging a pull request may close this issue.

3 participants