Skip to content

Open the related row, not the parent collection, from a relation chip#209

Merged
priethor merged 5 commits into
mainfrom
priethor/fix/relation-chip-opens-row
May 19, 2026
Merged

Open the related row, not the parent collection, from a relation chip#209
priethor merged 5 commits into
mainfrom
priethor/fix/relation-chip-opens-row

Conversation

@priethor

@priethor priethor commented May 19, 2026

Copy link
Copy Markdown
Collaborator

What

Relation chips now open the row they point to. A regular click uses the current detail mode: side peek, center modal, or full page. Cmd-click and other modified clicks still work like normal links.

Why

Clicking a relation chip should take you to that row, not back to its parent collection.

How

Row peek state now lives in the app shell, so table rows and relation chips use the same detail view. If you open a peek from one collection and then move to another, the peek stays open.

Relation refs now include row slugs, so chip URLs and full-page mode point at the row instead of the collection.

Testing Instructions

  1. Open a collection with a relation field that has at least one related row.
  2. Click a relation chip and check that the related row opens.
  3. With a peek already open, click another relation chip and check that the panel swaps content without changing mode.
  4. Open a row from collection A in side peek, navigate to collection B, and check that collection A’s peek stays visible.
  5. Cmd-click a relation chip and check that the browser handles the link.
  6. In Full page detail mode, click a chip and check that the URL ends in <slug>-<id> with no collection/ segment.

Screen recording

Grabacion.de.pantalla.2026-05-19.a.las.12.10.16.mov

priethor added 5 commits May 18, 2026 16:58
The frontend builds row URLs as <slug>-<id> elsewhere; carrying the
target row's slug in the relation payload lets relation consumers do
the same without an extra lookup. Existing keys are unchanged.
Introduces DocumentPeekProvider at app scope so a peek (side panel or
center modal) can host any row regardless of which collection it
belongs to, and survives route changes. Nothing calls openDocument yet;
this only adds the scaffolding. CurrentViewModeContext lets future
callers (chips inside a peek, cells inside a collection table) read the
mode of their surrounding surface.

rowRoute / rowHref in relationUtils mirror the existing collection
helpers but produce the document URI (no `collection/` prefix), ready
for the relation chip to consume in a follow-up commit.
CDV stops owning openRowId, the runDetailTransition orchestrator, the
side↔modal animation and the RowDetailView render. requestOpenRow and
openRowInMode now call openDocument with a source that carries the
visible row list (for next/prev), a refresh hook (autosave, restore),
and onModeChange (so the in-peek mode toggle still persists to
view.rowDetailMode for this view).

CurrentViewModeProvider wraps the table so relation chips inside a cell
inherit the configured row detail mode. Close-on-delete now calls
closeDocument. Behavior is identical for clicks inside a collection
table except that the peek now survives navigating to another
collection, which is the whole point of moving it up.
RelationReferences now calls openDocument on click, with rowHref as the
native anchor target so Cmd/middle-click still opens the row URL in a
new tab. The mode comes from CurrentViewModeContext (the surrounding
table's rowDetailMode, or the open peek's mode), so the chip respects
"how I like to see rows here" without inventing a new preference.

DocumentPeekHost moves to its own file so action-only consumers (chips,
collection cells) don't drag RowDetailView and the editor stack into
their module graph. The block editor preview of a data-view block also
mounts CollectionDataViews outside the app shell, so the action and
state hooks fall back to safe no-ops when no provider is present.

runTransition captures hasPendingEdits and source.refresh before
flushing, then calls refresh after the apply so a close-with-flush
still refreshes the table even though RowDetailView has unmounted by
the time autosave's onSaved would fire.

tests/js/setup.js polyfills TextEncoder/TextDecoder from node:util so
the tanstack router stack imports cleanly under jsdom. tech-debt notes
#37 and #43 pick up the new chip path, the rowRoute / rowHref helpers,
and the slug hydration in RowsController.
collectionHref, collectionRoute and navigateToCollection were the old
chip path; the row helpers replaced them and nothing in src/ or tests/
still imports them. topWindow goes with them since nothing else used
it.
@priethor priethor changed the title Open relation chips as row documents Open the related row, not the parent collection, from a relation chip May 19, 2026
@github-actions

Copy link
Copy Markdown

Performance vs main

Workload changed in 2 scenarios. 7 scenarios with notable timing changes.

Scenario Workload Timing
Load rows with many related records - p50 -14.4%
Load rows with a wide schema - p50 +11.7%
Open collection (cold) - rows API +72.8%
Paginate to rollups - rows API -22.2%, long tasks -20.8%
Open row detail - long tasks +91.3%
Open workspace home -1 REST request -
Warm shell navigation - rows API -45.0%
Navigate to next row -4 REST requests ready -39.4%, long tasks -66.7%

Full numbers in the job summary.

@priethor priethor merged commit e7ed398 into main May 19, 2026
11 checks passed
@priethor priethor deleted the priethor/fix/relation-chip-opens-row branch May 19, 2026 10:15
@priethor priethor added this to the 0.1.0 milestone May 28, 2026
@priethor priethor added type: enhancement Improvement to existing behavior. area: collections Fields, rows, views, DataViews, relations, rollups, formulas, and row properties. labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: collections Fields, rows, views, DataViews, relations, rollups, formulas, and row properties. type: enhancement Improvement to existing behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant