Skip to content

Limit Event description field to 200 characters (#1099) - #1150

Merged
busbyk merged 3 commits into
mainfrom
claude/event-description-limit-1099
Aug 25, 2026
Merged

Limit Event description field to 200 characters (#1099)#1150
busbyk merged 3 commits into
mainfrom
claude/event-description-limit-1099

Conversation

@rustynwac

@rustynwac rustynwac commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Description

Long event descriptions overflow the event preview UI (see #1099). This caps the Events description field at 200 characters and updates the field's admin helper text so editors know the limit up front.

Related Issues

Fixes #1099

Key Changes

  • src/collections/Events/index.ts — add maxLength: 200 to the description textarea and change its admin description from "Short description/summary for event previews" to "Short description/summary for event previews. Limit 200 characters.". Payload enforces maxLength both in the admin UI and on save (Local/REST API).
  • src/payload-types.ts — regenerated; the field's admin description flows through as the JSDoc comment on Event.description.

How to test

  1. pnpm seed, open localhost:3000/admin, create/edit an Event.
  2. The Description field shows the "Limit 200 characters." helper text; entering more than 200 characters fails validation on save.

Automated / verification:

  • pnpm tsc, pnpm lint, pnpm test (525 passing), pnpm fallow:audit — all clean.
  • pnpm payload migrate:create reports no schema changes (maxLength is validation-only; the SQLite column is unchanged), so no migration is included.
  • Ran a throwaway Local API script against a seeded DB: a 200-char description is accepted and a 201-char description is rejected (The following field is invalid: Description).

Screenshots

Over the limit, dark theme — the counter turns red:

counter-over-limit-dark

Over the limit, light theme — same state, theme-aware color:

counter-over-limit-light

Within the limit, dark theme:

counter-under-limit-dark

Within the limit, light theme:

counter-under-limit-light

Migration Explanation

None required — maxLength adds validation only and does not alter the database schema.

Future enhancements / Questions

  • The Courses collection has a description field with the same original helper text but was left unchanged, since this issue is specifically about Events. Happy to apply the same cap there if wanted.
  • ⚠️ Drift note: docs/events-and-courses.md is drift-bound to Events/index.ts, so the drift check will flag it as stale from this change. The doc prose is still accurate (it lists description as a field but doesn't document length constraints), so it just needs a re-link: drift link docs/events-and-courses.md src/collections/Events/index.ts --doc-is-still-accurate. I couldn't run this in my environment because the drift binary isn't installed there and couldn't be fetched.

🤖 Generated with Claude Code

https://claude.ai/code/session_016s7MJjeP8Mr3KRiRA22WwJ


Generated by Claude Code


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Long event descriptions overflow the event preview UI. Cap the Events
`description` textarea at 200 characters via Payload's maxLength (enforced
in the admin and on save) and update the field's admin description to
"Short description/summary for event previews. Limit 200 characters."

No migration: maxLength is validation-only and does not change the SQLite
column (migrate:create reports no schema changes). The regenerated
payload-types.ts picks up the new field description as a JSDoc comment.

Fixes #1099

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016s7MJjeP8Mr3KRiRA22WwJ
@github-actions

Copy link
Copy Markdown
Contributor

@rustynwac

Copy link
Copy Markdown
Contributor Author
image Passed the Rusty test

The doc doesn't document field validation limits, so it remains accurate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@busbyk

busbyk commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

@rustynwac Heads up before this merges: 32 published events currently in production already have descriptions longer than 200 characters. Nothing breaks retroactively — those events keep displaying fine and draft saves still work — but the next time someone edits and publishes one of them, it'll fail validation until the description is trimmed under 200. See those here.

If that's acceptable then cool - just want an explicit 👍 knowing the impact.

One more wrinkle: Payload doesn't render a live character counter on this field, so editors only find out via the helper text or the validation error at publish time. Should we add a character counter?

@rustynwac

Copy link
Copy Markdown
Contributor Author

Fine on historical events. I figured that would be the case.

If the validation error is explicit then that's good enough for now I think!

`maxLength: 200` is validation-only and Payload renders no counter, so editors
had no way to see how close they were to the limit until publishing failed. Add
a `DescriptionWithCharCount` field description component that appends a live
"used/allowed characters" count to the field's own `admin.description`, and wire
it into the Events `description` field.

The component reads both the helper text and the limit off the field config, so
it drops onto any textarea with a `maxLength` — Courses `description` next, if
that field gets the same cap. Once the value goes over the limit the counter
picks up the admin's `.text-error` class, which is theme-aware.

The field's `admin.description` loses its now-redundant "Limit 200 characters."
sentence, which is what changes the JSDoc comment in payload-types.ts.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@busbyk

busbyk commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Added a live character counter under the Description field so the 200-character cap is visible while typing instead of only surfacing as a validation error on publish.

  • New DescriptionWithCharCount field-description component (src/components/DescriptionWithCharCount/index.tsx) renders the field's existing helper text plus 137/200 characters, turning red once the value goes over the limit (theme-aware, uses the admin .text-error class).
  • It reads both the helper text and the limit off the field config, so it drops onto any textarea with a maxLength — relevant if the Courses description field gets the same cap.
  • Verified in the local admin UI: the count updates per keystroke and flags over-limit values.
  • The field's admin.description dropped its now-redundant "Limit 200 characters." sentence, which is the only reason payload-types.ts changed.

@rustynwac — worth re-checking on the preview deployment once it rebuilds.

Note this does not change the production-content picture: maxLength is still validation-only and drafts skip validation, so the ~30 of 49 production events already over 200 characters will still fail on their next publish. That's still the open question on this PR.

@busbyk
busbyk added this pull request to the merge queue Aug 25, 2026
Merged via the queue into main with commit 0402b69 Aug 25, 2026
15 checks passed
@busbyk
busbyk deleted the claude/event-description-limit-1099 branch August 25, 2026 20:06
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.

Field limit on Event Description field

3 participants