Skip to content

fix(ui): stop showing [Untitled] in the folder drawer during bulk edit - #17696

Open
luantaraschi wants to merge 1 commit into
payloadcms:3.xfrom
luantaraschi:fix/folder-drawer-title-in-bulk-edit
Open

fix(ui): stop showing [Untitled] in the folder drawer during bulk edit#17696
luantaraschi wants to merge 1 commit into
payloadcms:3.xfrom
luantaraschi:fix/folder-drawer-title-in-bulk-edit

Conversation

@luantaraschi

Copy link
Copy Markdown

Fixes #17669

Targeting 3.x per the PR template: this is a v3 bug fix. The folder UI was reworked into Hierarchy on main — there is no folder: translation namespace and no FolderView directory there — so the reported behaviour does not exist on v4.

What?

Bulk editing a folder field opened the folder-select drawer titled "Select folder for [Untitled]", even when a single, clearly named document was selected.

Why?

The chain, traced on 3.x at 57278bd9 (v3.87.1):

  1. elements/EditMany/DrawerContent.tsx:320 renders its fields inside a DocumentInfoProvider with id={null} and initialData={{}} — correct, since bulk edit has no document.
  2. providers/DocumentInfo/index.tsx:89 computes title via formatDocTitle({ …, fallback: id?.toString() }), so fallback is undefined.
  3. utilities/formatDocTitle/index.ts:76 — with no useAsTitle value and no string fallback — returns `[${i18n.t('general:untitled')}]`.
  4. FolderView/MoveDocToFolder/index.tsx:76 passed that value through as docTitle.
  5. MoveDocToFolderButton already has the right fallback at line 137:
    const titleToRender = docTitle || getTranslation(getEntityConfig({ collectionSlug }).labels.singular, i18n)
    but it never ran, because "[Untitled]" is a truthy string.

So the correct behaviour was already implemented — it was just unreachable.

How?

- docTitle={title}
+ docTitle={id ? title : undefined}

With no document id, docTitle is undefined and the existing fallback resolves to the collection's singular label: "Select folder for Post".

This also improves BulkUpload/EditForm, the other consumer of MoveDocToFolder, where new uploads have no id yet.

Added an e2e test in test/folders/e2e.spec.ts under Collection view actions, which asserts the drawer heading is exactly Select folder for Post after opening the folder chip from the bulk edit form.

Testing performed

I could not run the suite locally, and I would rather say so than imply otherwise. pnpm install fails on Windows during postinstall: @vercel/git-hooks throws EPERM: symlink creating .git/hooks/applypatch-msg, which aborts the lifecycle and leaves node_modules/.bin empty.

What I can state precisely:

  • The change narrows a prop declared as docTitle?: string to string | undefined, so it cannot introduce a type error.
  • The root cause is verified by reading the source at each of the five steps above rather than inferred, with file and line references so a reviewer can check each claim quickly.

Please have CI or a maintainer confirm the new test fails without the fix and passes with it.

Notes for the reviewer

Scope. The issue also reports that the chip renders the folder:noFolder label even when every selected document is in a folder. That has a different root cause — bulk-edit fields are setters and do not load current values — and arguably no single correct value exists across N documents. I left it out to keep this to one logical change; happy to take it in a follow-up if you want it addressed.

Why not a count-based heading. The issue suggests reusing the Move flow's "N Items" title. MoveToFolder does support that via action="moveItemsToFolder", but the count lives in useSelection(), and MoveDocToFolder is also rendered on the document edit view where no SelectionProvider exists — a hook call there would break. Fields are also rendered generically by the form, so the count cannot be threaded down as a prop to one specific field. The singular-label fallback needs no new plumbing and is already the component's declared intent.

EditMany renders its fields inside a DocumentInfoProvider with `id={null}` and
`initialData={{}}`. formatDocTitle then has no title and no string fallback, so
useDocumentInfo().title resolves to the `[Untitled]` placeholder.

MoveDocToFolder passed that straight through as `docTitle`, and because
`"[Untitled]"` is truthy, the existing `docTitle || <singular label>` fallback in
MoveDocToFolderButton never ran. Editors bulk editing a folder field saw
"Select folder for [Untitled]" even with a single, clearly named document selected.

Narrow `docTitle` to the document title only when a document id exists, so the
fallback resolves to the collection's singular label.

Fixes payloadcms#17669
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.

1 participant