Skip to content

Karpow that workspace folder!#614

Draft
hoyla wants to merge 3 commits intomainfrom
ljh-prev-next-doc-in-workspace
Draft

Karpow that workspace folder!#614
hoyla wants to merge 3 commits intomainfrom
ljh-prev-next-doc-in-workspace

Conversation

@hoyla
Copy link
Contributor

@hoyla hoyla commented Mar 14, 2026

Previous/next document navigation from workspaces

Partially addresses #470

When a user opens a document from a workspace, they can now use previous/next buttons (and shift+left/shift+right keyboard shortcuts) to cycle through sibling documents in the same folder — matching the existing behaviour for cycling through search results.

Why

Previously, the prev/next navigation only worked when a document was opened from search results. Users working through documents in a workspace had to go back to the workspace tab, click the next file, and wait for a new viewer tab to open. This is particularly tedious when reviewing many files in sequence.

How it works

  1. On double-click in workspace: Before opening the new tab, the workspace page writes the sibling leaf URIs (files in the same folder, in the user's current sort order) to sessionStorage.
  2. In the viewer tab: A useWorkspaceNavigation hook reads the sibling URIs from sessionStorage on mount and provides goToPrevious/goToNext functions.
  3. Fallback logic: The Viewer uses search result navigation when available, falling back to workspace navigation otherwise. Tooltips reflect the context ("Next result" vs "Next in folder").

This approach avoids any additional API calls — the workspace page already has the tree in memory, and sessionStorage is scoped to the originating tab so there's no leakage to shared links.

Design changes

The prev/next buttons have been redesigned:

  • Both buttons are now adjacent on the right side of the toolbar (instead of at opposite ends)
  • Icons changed from subtle chevrons to filled triangles for better visibility
  • Hover state and clearer active/inactive styling

Limitations

  • Navigation is scoped to siblings in the same folder, not the entire workspace tree. This keeps things performant for workspaces with hundreds of thousands of entries.
  • The new PageViewer (multi-page documents) doesn't yet have a footer toolbar, so prev/next only works for documents that fall back to the legacy viewer. This is being addressed separately - see Document view: consistent view mode switch UX, better wrapping sidebar #607

hoyla added 2 commits March 14, 2026 11:51
When a user double-clicks a file in a workspace, the sibling leaf URIs
(other files in the same folder, respecting the current sort order) are
written to sessionStorage. The viewer tab reads these on mount via a
useWorkspaceNavigation hook, enabling prev/next navigation through the
sibling documents.

This reuses the existing StatusBar prev/next buttons, falling back to
workspace navigation when search result navigation is unavailable.

- Add workspaceNavigation utility with storeWorkspaceSiblingUris,
  leafUrisOfChildren, findNodeById, and useWorkspaceNavigation hook
- Pass columnsConfig to respect the user's chosen sort order
- Wire workspace nav into Viewer via effectivePreviousFn/effectiveNextFn
- Connect through PageViewerOrFallback for the /viewer/:uri route
- Add tests for leafUrisOfChildren, findNodeById, storeWorkspaceSiblingUris
Move both previous and next buttons to the right-hand side of the
toolbar, adjacent to each other, so the user doesn't have to move their
pointer across the full width of the screen to cycle back and forth.

Replace the subtle navigate-before/navigate-next chevron icons with
filled triangle (play-arrow) icons for much better visibility. The
previous button uses a CSS scaleX(-1) flip.

- Add DocNavButton component with prominent 28x28px hit area
- Add hover state with translucent white background
- Inactive buttons render at 30% opacity
- Add doc-nav-button CSS classes for the new design
Only render KeyboardShortcut components for next/previous document
navigation when the effective navigation functions are defined,
preventing Mousetrap from trying to bind undefined as a callback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

document viewer feature Departmental tracking: work on a new feature ux/ui workspaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document viewer: revisit Previous and Next buttons ❤️❤️❤️

1 participant