getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 169 forks source link

Pages section “page” property does not to work #6735

Open linusrogge opened 1 month ago

linusrogge commented 1 month ago

Description

If I use the the page: 1 option on a section type: pages, it does not have any effect. No matter if I reload the panel, switch to another page and come back, or log out and in again—the localStorage item (eg. kirby$pagination$/pages/entries/entries with a value of 3) will be saved and I will land on the page where I previously left off.

In the docs, it says “Sets the default page for the pagination. This will overwrite default pagination.” What is the default pagination? Am I understanding this property wrong or does it actually not work?

Looking at the kirby source in

https://github.com/getkirby/kirby/blob/eb47158e91e74184ab291ede020664f1d2829f74/config/sections/pages.php#L12-L24

and also in

https://github.com/getkirby/kirby/blob/eb47158e91e74184ab291ede020664f1d2829f74/config/sections/pages.php#L316-L336

there does not seem to be anything about the page option. Or should it be included in the pagination prop? Also in the Vue Component (and the ModelsSection.vue) there is not a line about this.

Expected behavior

The pages section should reset to the given page after a reload, changing pages or logging out and in again. So on each visit, so to say, it should start whatever I set the page option to.

To reproduce

  1. Create a type: pages section
  2. Set page option to 1
  3. Fill in data to have multiple pages
  4. Navigate to page 2 and reload/log out and in/switch pages and come back
  5. The section is still on page 2

Your setup

Kirby Version

4.4.1

Your system (please complete the following information)

afbora commented 1 month ago

Summary

This issue happens for two reason:

  1. Default request is 1 https://github.com/getkirby/kirby/blob/4.4.1/panel/src/components/Sections/ModelsSection.vue#L199-L200
  2. When pagination changed, it stored into kirby$pagination$* local storage.

What should we do? Should we also clear localStorage when the session is ended (logged out) or should we always prioritize the defined page option when the page is first loaded?

linusrogge commented 1 month ago

I would prefer always landing on the defined page, not only on each new session. At least that’s what this option means to me, judging from the docs. It led to confusion multiple times both for me and clients who use Kirby.