-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Feature: prev next button for detail and edit views #9165
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…store it in the context
fzaninotto
requested changes
Aug 11, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're headed in the wrong direction
packages/ra-core/src/controller/list/ListIdsContextProvider.tsx
Outdated
Show resolved
Hide resolved
fzaninotto
requested changes
Aug 11, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's the right direction!
…when PrevNextButton is displayed out of context like in Create component
djhi
requested changes
Aug 18, 2023
fzaninotto
approved these changes
Aug 21, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Some users want to navigate to the previous and next item in a list without going back to the list.
Solution
Create a ListIdsContextProvider, which fetches all the list and stores only an array of ids in it. It can take optional filters and sort params. If not given, it uses the params from the store (${resource}.listParams), or the default ones.
Create a prev/next component. It creates a ListIdsContextProvider. Using the RecordContext, it looks up the current record id in the list of ids, determines the previous and next id, and forges the link to the next page (either a show or an edit page, depending on the current route)
Todo
add context and contextProvider to fetch ids according to the filters and sort parametersadd a PrevNextButton component that consume the above context and display links to navigate between resourcesPrevNextButton
component and make it worksPrevNextButton
PrevNextButton
PrevNextButton
useNextPrevController
PrevNextButton
documentationwriteuseNextPrevController
documentation