Skip to content

feat(collections): let visitors browse designed indexes and collection lists - #1765

Merged
gregpriday merged 8 commits into
developfrom
feature/issue-1730-add-visitor-browsing-to-collection-indexes
Nov 28, 2026
Merged

gregpriday merged 8 commits into
developfrom
feature/issue-1730-add-visitor-browsing-to-collection-indexes

Conversation

@gregpriday

Copy link
Copy Markdown
Member

Follow-up to #1402: visitor search, filters and sorting now also work on a collection index with its own design, and on collection listing sections.

Resolves #1730

What changes

An index with its own design (archiveTemplate) browses while its layout has a loop over the page's entries ({ $archive: true }) that the page shows. The browse index (collections/<id>.js) holds each published entry's match data and its projected row for each such loop, built by the same prepareLoops that writes the page's own rows, so a matching entry from page 3 looks exactly as it would there. The page writes the layout once, inside the browse component's content snippet: each $archive loop shows the page's own rows until a control is used, then the rows that match. The controls sit under the archive heading (a frame snippet). The More button takes the place of the page links (content's second argument). Pages 2 and later, and term archives, are unchanged. A layout with no such loop says in Index settings, and to the assistant (browseOff), that the index has none of it.

Collection listings. A connected list (listSources[prop].browse: true) or a query loop ({ $query, browse: true }) opts in beside the query, never inside CollectionQuery, so it never changes which rows show. The listing browses exactly the rows its query, sort, offset, limit and the list's max chose, using the controls the collection's browse setting offers. Choice options are limited to those its own rows have. Its rows and match data are declared once in that file's script (so_rows_N, so_browse_N), so a page showing six records ships six and never loads the collection's index. Each listing gets its own SoBrowse, and several on one page (or in the header and footer) are independent. The controls go above the element holding the listing, moving up past lists, text, rows, grids, tags a property chooses and linked cards. They never move out of what shows and hides the rows: a slot's content, a disclosure, a dialog or tab panel, an element hidden at some screen size, or one shown only while a condition holds. A listing whose controls could only sit inside a link, a list or text shows without them.

Reused as they are: collection-browse.js, the control kinds and the matching code. CollectionBrowse.svelte gains optional content and frame snippets beside the ready-made results/children path. Its controls are now a <div role="search">, not a <form>, and every control names an empty form. A listing inside an author's form never nests forms, and pressing Enter or typing a half-finished number never touches that form. The ready-made index (#1402) behaves as before. In an author's design, Show more focuses the first newly shown thing a keyboard can reach, or the status.

Editing.

  • The inspector has a "Visitors can search, filter and sort" switch in ListSourceSwitch and LoopSourceControls. Query and mapping edits keep it.
  • While the switch is on, the collection's browse choices show beneath it. CollectionBrowsing moved out of PagesPanel.tsx so lists-only collections can be set too.
  • instance.setListSource and node.setRepeatSource take browse: true. normalizeConnection and loopProblem validate it, and a hand edit gets a browse-specific message.
  • connect_collection_list takes browse and keeps the current value when the call leaves it out.

Export. A designed index's loop rows count as page content (their pictures ship). The listings' inline match data is skipped, but only lines that parse as generated match data, so an entry's sort text never keeps a file and authored code is never stripped. A code component that places the browse component keeps the runtime files.

Testing

  • New: tests/unit/collection-browse-lists.test.ts covers the opt-in shape and validation, exact listing rows, controls limited to a listing's rows, host placement past a grid, list and linked card, shared header/footer numbering, reserved names, designed-index rows, detached loops, the assistant tool, and the generation cache against a full run.
  • New: tests/unit/collection-browse-lists-visitor.test.ts runs in Chromium. It renders on the server and hydrates two independent listings on one page, and a designed index searched across pages with Show more, zero matches and Clear. It checks that no extra script loads.
  • New: tests/unit/collection-list-browse-browser.test.ts covers the inspector switch's ops.
  • A new Add visitor browsing to collection indexes with their own design and to collection listing sections #1730 case in tests/unit/export.test.ts. Two existing assertions in tests/unit/collection-browse.test.ts that encoded "a design of its own never browses" now encode the new rule.
  • Own and adjacent tests: 67 files green. Impact set: 73 of 724 test files (10%), all green, locally, after the final rebase. Typecheck green. No lint or formatter is configured in the repo.
  • Left open from the final review, all edge cases in where a listing's controls go, none High:
    • a tag bound to an enum that can be <details> is climbed past, so the controls can sit outside a collapsed disclosure;
    • a <ul>/<ol> that is hidden on phones and holds the loop directly leaves the listing without controls at every width;
    • a row that is hidden on phones and holds the loop directly takes the controls as one more flex item;
    • a component root bound to an li-only tag, placed in a <ul>, can have the controls placed directly in the list.
  • Left open as pre-existing, not introduced here:
    • a connected feed list still ships its feed rows beside its connected ones;
    • the inspector hides the connected-list controls for feed lists;
    • an isolated preview of an archive placement doesn't resolve $current;
    • the inspector's controls each send the whole connection;
    • connect_collection_list caps a query's limit at 100.

…n listings

- browse: true on a connected list or a query's loop, kept apart from the query
- designed indexes browse their own loops over the page's entries
- the browse component takes a content snippet and a frame for the controls
…listings

- unit: the switch beside the query, validation, listing payloads, designed index rows, cache
- browser: two listings on one page, a designed index, and the inspector switch
- export: browse data names no file, designed rows keep their pictures
…p each file's browse data its own

- controls climb past lists, text, rows, grids and linked cards, never out of a slot, dialog or panel
- the footer's listings are numbered and declared with the header's
- browse snippets and declarations take names no property's local can
- export strips only genuine browse data, written with line separators escaped
- code that places the browse component keeps its runtime; detached archive loops browse nothing
- browse-specific diagnostics, focus after Show more skips hidden links
… and out of any form

- the controls are a search landmark, not a form, so a listing inside a form leaves it whole
- the climb stops at a conditional element, a placement's slot content and a disclosure, and never lands on a repeated item
- placed among a grid's items, the controls take the whole row
- export strips browse data only in generated files, rows with values
… where their rows show

- every control names a form that is not there, so Enter or a half-typed number never touches an author's form
- the climb stops at a node hidden at some screen size and at a bound tag, and falls back below a list it cannot leave
- a listing that could only have controls inside a link shows without them
- export reads a code component's file whole, whatever note it keeps
…des at a screen size

- a tag a property chooses may be text: the controls climb past it, and with nowhere valid the listing has none
- an element hidden at some screen size holds the controls with its rows
- the controls name an empty form, which no form's ID can match
@gregpriday
gregpriday merged commit 7f477e9 into develop Nov 28, 2026
1 check passed
@gregpriday
gregpriday deleted the feature/issue-1730-add-visitor-browsing-to-collection-indexes branch November 28, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add visitor browsing to collection indexes with their own design and to collection listing sections

1 participant