Skip to content

Add Previous/Next navigation between detail views (#12397) - #12510

Open
jdjioe5-cpu wants to merge 1 commit into
inventree:masterfrom
jdjioe5-cpu:feature/issue-12397-prev-next
Open

Add Previous/Next navigation between detail views (#12397)#12510
jdjioe5-cpu wants to merge 1 commit into
inventree:masterfrom
jdjioe5-cpu:feature/issue-12397-prev-next

Conversation

@jdjioe5-cpu

Copy link
Copy Markdown

Resolves #12397

Adds a generic Previous/Next icon-button pair to entity detail pages so users can step between sibling instances without returning to the list view, matching the suggestion from the issue.

What changes

  • NextPrevAction — a small, dumb presentational component that renders two compact ActionIcon buttons (IconChevronLeft / IconChevronRight). It is intentionally model-agnostic: the caller resolves the destination pk and onClick and the component just disables the button when the target is undefined. It is exported from lib/ so frontend plugins and other detail pages can reuse it.
  • useNextPrevSiblings — a React-Query hook that queries the InvenTree REST API for the previous / next sibling using pk__lt / pk__gt filtering and the same ordering parameter the list view uses. Only two single-row queries are issued per detail page, so the cost is independent of list length.
  • PageDetail now accepts an optional nextPrev prop and renders the action next to the existing actions group. The button is placed before the action icons so it stays close to the title area without crowding the rest of the toolbar.
  • PartDetail is the first call site. It filters by the part's current active and assembly flags so the navigation stays within a coherent subset; this matches the spirit of the issue ("only for the filtered items") while staying conservative until a richer filter-context API is available.
  • When a side has no sibling (e.g. the first or last item in the filtered set), the corresponding button is disabled instead of hidden, so the affordance is consistent across detail pages.

Why this design

The issue explicitly asks for navigation scoped to the originating filter list. Rather than reimplement filter state on the client, the hook reuses the existing list API and only asks for one record per direction. This keeps the implementation small, keeps it correct under any list-ordering policy, and avoids duplicating the filter-parser logic.

The component is split out of PartDetail so future work can wire it into StockItemDetail, PurchaseOrderDetail, etc. without copy-pasting icon code. See PageDetail for the single integration point.

Tests

  • tests/pui_part_next_prev.spec.ts — Playwright regression that renders the detail page, asserts both buttons appear via stable data-testid hooks (inventree-prev-item, inventree-next-item), clicks next and prev, and verifies that the disabled-state fallback also works on single-item datasets.
  • The new TypeScript code passes tsc --noEmit cleanly.

Refs #12397

Adds a generic NextPrevAction icon-button pair and a useNextPrevSiblings
hook that resolves the adjacent instances via the existing REST API.

* The component is intentionally model-agnostic and lives in the lib
  surface so plugins and other detail pages can reuse it.
* PartDetail now renders the action next to the existing action group,
  scoped to the part list's active filter set. The same plumbing can
  be wired up to other detail pages in follow-up changes.
* When the current instance has no sibling in a given direction, the
  corresponding button is disabled instead of hidden, so the affordance
  is consistent.
* A Playwright regression test renders the buttons on the seeded
  part-detail page and verifies the click navigation behaviour.

Refs inventree#12397
@netlify

netlify Bot commented Jul 30, 2026

Copy link
Copy Markdown

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 8761766
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6a6bd216c59ded000829f611
😎 Deploy Preview https://deploy-preview-12510--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 97 (no change from production)
Accessibility: 81 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@SchrodingersGat SchrodingersGat added the User Interface Related to the frontend / User Interface label Jul 31, 2026

@matmair matmair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Labels

User Interface Related to the frontend / User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR] Add Next and Previous Icon to switch easily between 2 objects

3 participants