Skip to content

feat(list): move filters to a list toolbar with a sort selector #75

Closed

Description

@Ardnived

Summary

Replace the icon-only filter button in the drawer header with an explicit, labeled toolbar at the top of the event list. The Search results list gets a Filters button (opening the existing FilterView) plus a Sort by menu — Recommended (default), Closest, Soonest — persisted in the URL so a shared link keeps its sort. The root Countries list keeps a Filters-only button (sorting a browse index of countries has no meaning). This surfaces sorting — today a hardcoded relevance score with no UI — and turns filter access into a legible labeled control instead of a bare funnel glyph. Modeled on the Aesop "Filters / Sort: Featured ⌄" toolbar (screenshot in the discussion).

Proposed changes

Remove the header filter button

  • Drop <FilterButton /> from the SearchView header (src/views/SearchView/SearchView.tsx:79) and the CountriesView header (src/views/CountriesView/CountriesView.tsx:79). The header keeps the search field + close/collapse controls only.

Add a list toolbar

  • New molecule (e.g. ListToolbar) at the top of the list — above the ActiveFilterPills row — laying out a left-aligned Filters button and a right-aligned Sort by menu (a justify-between flex row), mirroring the screenshot.
  • Filters button — a labeled ghost Button (variant="ghost") that opens the FilterView by navigating to <current>/filters (the existing FilterButton behavior, src/views/shared.tsx:155-182), preserving the current query. Keep the active count in the label (e.g. Filters (2)) via activeFilterCount(useEventFilters()).
  • Sort menu — a ghost Button trigger showing Sort: <current label> with a DownArrowIcon caret, opening a menu of the three options with a check on the active one. Reuse the selectable-menu pattern from SettingsMenu (src/components/molecules/SettingsMenu/SettingsMenu.tsx): Radix DropdownMenu.RadioGroup + RadioItem + ItemIndicator + CheckIcon. Do not use the floating Dropdown atom (no selection model) or the Select atom (form-field look, no checkmark).
  • Render both controls on SearchView; render the Filters button only on CountriesView.

Sort orderings (applied client-side, no refetch)

  • Store the selection in the URL as ?sort= (default recommended, omitted). It is presentation, not a predicate: keep it out of filtersToParams/filtersFromParams, out of filtersKey (no refetch), out of matchesFilters, and out of activeFilterCount (never lights the badge).
  • Apply it at the existing re-sort step in DynamicEventsList (src/components/organisms/EventsList/EventsList.tsx:66-71) by choosing a comparator:
    • Recommended (default) — current calculateOrder relevance score (src/components/organisms/EventsList/EventsList.tsx:32-43).
    • Closest — ascending distance (a.distance ?? Infinity); placeless/online last.
    • Soonest — existing byNextOccurrence (src/lib/shape/event.ts:32), keyed on schedule.upcomingDates[0]; undated last.
  • A small hook pair (e.g. useSortOrder / useSetSortOrder) reads/writes ?sort= with a { replace: true } navigation that preserves all other params (mirror useSetFilters, which starts from the previous params — src/hooks/use-filters.ts:33-37).
  • Carry sort through the two query rebuilds that reconstruct the URL from the filter codec and would otherwise drop it: SearchField.handleSelect and NearbySuggestion.handleSelect (both in src/views/shared.tsx) call filtersToParams(filtersFromParams(searchParams)) — searching a new place or accepting the nearby prompt must keep the current sort.

i18n

  • Add new keys across all locales (not en-only) via pnpm i18n:add: a Sort: / "Sort by" label and the three option labels. "Filters" already exists (common.json → filters.title). Derive from a sibling string where possible.

Recommended sort options

The three requested — Recommended / Closest / Soonest — already cover the meaningful axes (relevance, space, time) and each maps to an existing comparator, so no new data or API field is needed. An alphabetical (A–Z) option is possible but low-value for a nearby-events atlas — not recommended. Ship exactly the three.

Acceptance criteria

  • The icon-only filter button is gone from both the Search and Countries drawer headers.
  • SearchView shows a toolbar at the top of the list with a Filters button (left) and a Sort by menu (right), above the active-filter pills.
  • The Filters button opens the FilterView and shows the active-filter count in its label; applying filters works exactly as before.
  • CountriesView shows the same Filters button at the top of its list, and no sort menu.
  • Both controls use the Button atom with variant="ghost"; the sort trigger shows a DownArrowIcon caret and the current selection.
  • The sort menu offers Recommended (default), Closest, Soonest, with a checkmark on the active option; selecting one re-sorts the visible list with no network refetch.
  • Recommended = current relevance order; Closest = ascending distance; Soonest = next-occurrence order — verified against a seeded feed.
  • Selection persists in ?sort= (default omitted); reload / shared link reopens with the same sort; searching a new place or accepting the nearby prompt keeps the current sort.
  • Sort never counts toward the filter badge and never triggers an events refetch (absent from filtersKey/matchesFilters/activeFilterCount).
  • New sort/label keys exist in every public/locales/*/common.json, not en-only.
  • Lint + typecheck + test:run + build pass.
  • Verified in the running widget.

Files affected

  • src/views/shared.tsx — labeled ghost FilterButton; carry sort through SearchField + NearbySuggestion rebuilds.
  • src/views/SearchView/SearchView.tsx — drop header button; render Filters + Sort toolbar.
  • src/views/CountriesView/CountriesView.tsx — drop header button; render Filters-only toolbar.
  • src/components/molecules/… — new ListToolbar + SortMenu molecule(s) + barrel update.
  • src/components/organisms/EventsList/EventsList.tsx — comparator selection at the re-sort step.
  • src/hooks/use-filters.ts (or a new use-sort.ts) — useSortOrder / useSetSortOrder.
  • src/lib/shape/ — sort-key type + the ?sort= param name (separate from the filter codec).
  • public/locales/*/common.json — new labels via pnpm i18n:add.

References

  • Screenshot: Aesop "Filters / Sort: Featured ⌄" list toolbar (discussion).
  • Selectable-menu precedent: src/components/molecules/SettingsMenu/SettingsMenu.tsx.
  • Current relevance sort: src/components/organisms/EventsList/EventsList.tsx:32-71.
  • Soonest comparator: src/lib/shape/event.ts:32 (byNextOccurrence).
  • Filter URL codec / state: src/hooks/use-filters.ts, src/lib/shape/filters.ts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions