Switching list-view tabs (All / By Folder / Trash) wipes the collection's saved preferences (columns, sort, limit)
Describe the Bug
DefaultListViewTabs saves which sub-view is active with:
// @payloadcms/ui/dist/elements/DefaultListViewTabs/index.js (3.87.0, ~line 41)
await setPreference(`collection-${collectionConfig.slug}`, {
listViewType: newViewType
});
setPreference defaults to merge = false (providers/Preferences/index.js, line 76), so this call replaces the entire collection-<slug> preference record with { listViewType } — silently destroying the user's saved columns, sort, limit and any other list preferences, every time they click between "All
We confirmed the mechanism by reading the payload-preferences record before/after a tab click: a record containing { limit, columns, listViewType } is reduced to { listViewType: "folders" } by a single click on the By Folder pill.
This hits folder-enabled upload collections hardest: users add the Folder column, visit By Folder to organise, come back — and their column setup is gone. Non-technical editors experience this as "my columns keep randomly disappearing".
Reproduction steps
- Any collection with
folders: true(ortrash: true) so the tab pills render. - In the list view, add a column via the Columns panel (e.g. Folder). Confirm the
collection-<slug>preference record now containscolumns. - Click By Folder, then All
. - The added column is gone; the preference record contains only
{ listViewType }.
Expected / Actual
- Expected: switching tabs remembers the active sub-view without touching other saved preferences.
- Actual: every tab switch replaces the whole preference record.
Proposed fix
Pass the existing merge flag (one argument):
await setPreference(`collection-${collectionConfig.slug}`, {
listViewType: newViewType
- });
+ }, true);
Note the same handler is also inlined (minified) in dist/exports/client/index.js, which is what some import sites actually execute — the fix needs to land in the source so both builds pick it up. We've been running this exact change in production via a pnpm patch with no side effects.
Environment
- Payload: 3.86.0 (found), verified still present in 3.87.0 source
- @payloadcms/db-postgres, @payloadcms/next
- Next.js: 16.2.11
- Node: 22.14.0
- pnpm 10.30.3, macOS / Vercel
Hey! Thanks for writing up such a clear reproduction for this bug. I just opened a PR (#17680) to get this fixed.
As suggested, it was just a matter of adding the true merge flag to the setPreference call in DefaultListViewTabs so it doesn't wipe out the existing column/sort setups. Hopefully, this gets merged soon!
Thanks for looking at it.