feat: Add generic previous/next navigation between detail views (closes #12397) - #12511
Open
chidii wants to merge 2 commits into
Open
feat: Add generic previous/next navigation between detail views (closes #12397)#12511chidii wants to merge 2 commits into
chidii wants to merge 2 commits into
Conversation
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Member
|
This approach leads to differing behaviors when a user shares the link to the page they currently have open - user 1 sees the nav, user 2 not; the filter, ordering etc need to be somewhere in the url path so that behavior is consistent and repeatable I like the overall approach; the implementation should stire in a way where the logic is implemented in the generic components so that plugins do not need to re-implement all this logic. Similar to the approach that is taken with the InvenTreeTable component |
This file contains hidden or 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
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.

Closes #12397
Design
Answers the two open questions from the issue thread:
at row-click time in InvenTreeTable and stored in a small zustand slice
(useLocalLibState, alongside the existing detailDrawerStack pattern). Prev/next on the
detail page resolve as O(1) lookups into that exact list the user was viewing - not
just "next by pk". No stored context (direct link, plugin embedding) falls back to an
ordering-aware pk__gt/pk__lt query.
stored context and the next available neighbor is fetched automatically.
Generic for plugins
nextPrevis a first-class optional prop onPageDetailitself(
{hasPrev, hasNext, onPrev, onNext}), not per-page logic. Any page or plugin usingPageDetail/Instancegets it by callinguseNextPrevInstance- no copy-pasted filtercode per detail page.
Changes
hooks/UseNextPrevInstance.tsx(new) - peer touseInstance, resolves prev/next pkstates/LocalLibState.tsx- addslistNavContexts(excluded from persistence -ephemeral navigation state, not a user preference)
components/nav/PageDetail.tsx- renders prev/next chevrons + alt+←/→ hotkeys whennextPrevis suppliedpages/part/PartDetail.tsx- first integrationNot yet done
listNavContexts(needs review againstactual table component)