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

Navigating back from a record in a GridField doesn't respect selected pagination or filters #9380

Closed
Tracked by #503
phptek opened this issue Jan 22, 2020 · 8 comments

Comments

@phptek
Copy link

phptek commented Jan 22, 2020

Affected Version

vagrant@anonsite: (develop) $> composer info silverstripe/framework | grep versions
versions : * 4.4.3

Description

  • [OK] Login to the admin UI
  • [OK] Navigate to any ModelAdmin containing a GridField comprising >1 "page" of results
  • [OK] Navigate to page 2 using the controls in the Grid Field Footer
  • [OK] Select any record
  • [OK] Select the back control "<" (Top LHS of main)
  • [FAIL] I am taken back to the selected page (page 2) of the GridField. I am instead taken back to the first page, meaning I need to navigate using the arrows or type a number into the field, to take me back to where I was (If indeed I even committed this to memory)

Steps to Reproduce

See above.

Parent issue

Related issue

PRs

@emteknetnz
Copy link
Member

Thanks for reporting this 👍

@chillu
Copy link
Member

chillu commented Jun 23, 2020

I'm upgrading this to impact/high since it's such a common user action

@GuySartorelli
Copy link
Member

After clicking the back button, the gridstate in the URL does still say the page number you were on originally, so the information is definitely available, it's just not being used for whatever reason.

@GuySartorelli GuySartorelli self-assigned this May 19, 2022
@GuySartorelli
Copy link
Member

Okay, so there are a few moving pieces here.

  • The state that I see being added to the end of the URL is from the GridFieldEditButton and is intended to aid GridFieldDetailForm_ItemRequest - it's not even available if you visit the form after clicking on the view button.
  • State can be 'hydrated' from the URL using the GridFieldStateManager - item request has access to that via the GridFieldStateAware trait.
  • For that to be a valid solution, the edit button would need to also add the state to the URL.
  • The above would be fine for using the 'back' button in the edit form, but would not work for the browser back button (which is likely to be used more often than the one in the form, I'd think).
    • To enable the back button to work as well, we'd need to ensure both the current state as well as any transformations are exposed in javascript, so that we can use (for example) window.history.replace() so that when the gridfield reloads from an ajax request, the current history item is replaced to include the new schema so that back/forward works as expected.

@GuySartorelli
Copy link
Member

GuySartorelli commented May 22, 2022

A potential solution (which involves a lot of effort and is a breaking change, but I think is the cleanest solution) was suggested by @sminnee on another issue:

FYI I've suggested building on #9190 to fix this by getting grid field state pushed into the URL via the history API, and have it be managed by GridField itself rather than selected components.

@GuySartorelli GuySartorelli removed their assignment May 22, 2022
@GuySartorelli
Copy link
Member

https://github.com/isobar-nz/silverstripe-persistentgridfield is relevant for anyone coming across this in the meantime.

@GuySartorelli GuySartorelli changed the title Navigating back from a record in a GridField doesn't respect selected pagination Navigating back from a record in a GridField doesn't respect selected pagination or filters Jun 13, 2022
@sabina-talipova
Copy link
Contributor

sabina-talipova commented Jun 22, 2022

@sabina-talipova
Copy link
Contributor

Solved by silverstripe/silverstripe-admin#1314

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

No branches or pull requests

5 participants