Skip to content

Folder move fails with localized alt text validation #95

@fkkehlet

Description

@fkkehlet

Describe the bug

Moving media to a folder fails with a validation error when using localization with fallback: false and a locale has no alt text. The plugin's custom validate function on the alt field treats all falsy values as invalid on updates (!value || value.trim().length === 0), which blocks folder moves for locales that were never filled in.

Payload fixed locale-aware folder operations in v3.56.0 (payloadcms/payload#13818), but the plugin's custom validate still runs across all locales during the update, causing the operation to fail.

To Reproduce

  1. Enable localization with fallback: false and configure the alt-text plugin on a media collection with folders: true
  2. Upload a media item and add alt text in the primary locale only (e.g. English), leaving other locales (e.g. Spanish) empty
  3. Try to move the media item into a folder via the admin UI
  4. See validation error: "An alternate text is required." for the unfilled locale

Expected behavior

Moving media to a folder should succeed regardless of alt text presence in non-active locales. Folder moves are metadata operations and should not trigger content validation.

Package(s) version:

  • @jhb.software/payload-alt-text-plugin: 0.4.4
  • payload: 3.82.1

Additional context

The issue is in dist/fields/altTextField.js. The validate function rejects null/undefined values (unfilled locales) the same as empty strings (explicitly cleared). A possible fix is to only enforce validation when value is a non-null empty string:

if (value != null && typeof value === 'string' && value.trim().length === 0) {

Workaround: patch the plugin via pnpm patch to set required: false and guard the validate against nullish values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions