Skip to content

fix(richtext): default Upload align to center (closes #318) - #335

Merged
Ardnived merged 1 commit into
mainfrom
fix/318-upload-block-align-validation
Apr 30, 2026
Merged

Ardnived merged 1 commit into
mainfrom
fix/318-upload-block-align-validation

Conversation

@Ardnived

Copy link
Copy Markdown
Contributor

Summary

  • The Upload feature's align field was required: true with no default, so inserting an Upload node into a Page (or saving an existing one) failed with upload node failed to validate: The following fields are invalid: align whenever the user didn't open the extra-fields drawer.
  • Adds defaultValue: 'center' so fieldSchemasToFormState populates the field before the required-field check runs. Verified against the PayloadCMS source: calculateDefaultValues always runs (create and update), and the default-value promise fills any undefined value before validation.
  • No DB migration needed — node.fields is stored inline in the rich-text JSON, and old rows without align simply get the default applied at validation/save time.

Closes #318

Test Results

  • Integration tests: 585 passed, 1 pre-existing flaky failure (access-performance.int.spec.ts > completes 10,000 visibility checks in under 150ms — passes in isolation at ~7ms; only fails under full-suite CPU contention; not introduced by this PR).
  • E2E tests: N/A (none defined in tests/e2e/)
  • Build: ✓ Success
  • Lint: ✓ No warnings or errors

New regression coverage

  • tests/int/pages.int.spec.ts > Lexical Upload Node > saves an upload node without an explicit align value (defaults to "center")
  • tests/int/pages.int.spec.ts > Lexical Upload Node > preserves an explicitly-set align value
  • New createLexicalWithUploadNode(imageId, fields?) helper in tests/utils/lexicalTestHelpers.ts.

Test plan

  • Add an Upload block to a Page in the admin UI without opening the extra-fields drawer → saves cleanly with fields.align === 'center'.
  • Save an existing page that contains an Upload block → no validation error.
  • Change align via the extra-fields drawer to Left / Right / Wide → persists as chosen.

The `align` field on the rich-text Upload feature was `required: true`
with no default. Inserting an Upload node in a Page leaves
`node.fields.align` undefined unless the user opens the extra-fields
drawer and picks a value, so the server-side validator failed with
"upload node failed to validate: The following fields are invalid:
align" — both for newly-added blocks and any previously-saved page
that contained one.

Adding `defaultValue: 'center'` lets `fieldSchemasToFormState` populate
the field before the required-field check, fixing both cases without a
DB migration. Also adds a regression test and a
`createLexicalWithUploadNode` test helper.
@Ardnived
Ardnived merged commit a090fce into main Apr 30, 2026
@Ardnived
Ardnived deleted the fix/318-upload-block-align-validation branch April 30, 2026 11:24
Ardnived pushed a commit that referenced this pull request Nov 4, 2026
`refuseDuplicateClass` ran on every update, so a class that already had a twin
could never be saved again — a manager's edit, or the bookkeeping write a
registration triggers, which took the registration down with it. The rehearsal
lost 10 registrations to it, and production holds such pairs today. An update
is now checked only when its region or class key moves.

The atlas importer also skips, by name, an inactive listing with neither a
phone nor an email, which Events refuses (#335's only contact is a Meetup
page), and the events floor mirrors it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ardnived added a commit that referenced this pull request Nov 5, 2026
…it (#1079)

* feat(atlas): repeatable re-sync pipeline, with the data kept out of git

The Atlas seed data was a one-off extraction whose grooming lived only in a
committed events.json, so refreshing it meant redoing the curation by hand —
and the files carried registrant and manager personal data into this public
repository. This makes the refresh a repeatable, local pipeline.

- `pnpm atlas:sync` (seeds/atlas/sync/): fetch captures a Heroku backup of the
  legacy Atlas, restores and extracts it; build lays a grooming overlay and the
  merge decisions over it and writes the importer's input, a delta report and a
  grooming worksheet; groom applies a mechanical clean plus a hand-written
  patch; check enforces the grooming and write-contract invariants; record
  turns the groomed data into the next overlay. A rebuild reproduces the
  groomed data byte for byte.
- seeds/atlas/data/ is gitignored and removed from the tree; the CLI already
  uploads it as inlineData. Its data specs move into `check`.
- Verification floors are derived from the data on every build and ride in
  the uploaded manifest (`from-data` floors), so no refresh leaves a stale
  constant. Merge decisions move to sync/merges.ts and apply locally, so a new
  one needs no deploy.
- `pnpm seed atlas-reset` empties events, regions, users and user-submissions
  in one transaction below the Local API, refusing if a RESTRICT key appears;
  `--update` now prunes managers Atlas deleted, keeping any SahajCloud gave
  something to.
- extract.ts reads Atlas's `timestamp without time zone` columns as UTC and
  dates as dates: every timestamp was shifted by the operator's UTC offset,
  and the same dump extracted in two zones disagreed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(atlas): atlas-reset refuses while a non-Atlas client points at a region

Deleting regions nulls every client's region, and the import re-links only the
clients Atlas created, so a SahajCloud-made client would lose its region.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(atlas): import one-offs as one-offs, and keep Atlas's unmerged pairs

The preview rehearsal's clean import fell 16 events short of its floor.

- Atlas stores a single session or a concert as `type: daily` with no end, so
  the importer listed every past concert as repeating daily forever.
  `isAtlasOneOff` maps it to a schedule that does not repeat.
- `refuseDuplicateClass` (#912) shipped after production was seeded and
  refused every pair the grooming passes left unmerged on purpose (two
  managers, one slot), plus the concerts above. The seed now skips it through
  `context.skipDuplicateClassCheck`: Atlas's duplicates are decided by evidence
  in sync/merges.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(events): check a class for repeats only when its identity changes

`refuseDuplicateClass` ran on every update, so a class that already had a twin
could never be saved again — a manager's edit, or the bookkeeping write a
registration triggers, which took the registration down with it. The rehearsal
lost 10 registrations to it, and production holds such pairs today. An update
is now checked only when its region or class key moves.

The atlas importer also skips, by name, an inactive listing with neither a
phone nor an email, which Events refuses (#335's only contact is a Meetup
page), and the events floor mirrors it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(atlas): reuse an earlier upload of each event picture

Storage renames an upload, so MediaUploader's filename match never found the
earlier copy, and every run uploaded all 130 Atlas pictures again — a re-sync
keeps images through atlas-reset, so each one would have doubled them. Match
on the picture-<legacyId>- stem the renaming keeps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(seed): the seed route accepts every script, atlas-reset included

Its own hand-kept list had drifted from the CLI's. Derive it from
EXPECTED_COUNTS, which the type system makes complete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(atlas): atlas-reset shows the operator what it counted and deleted

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(seed): a draft upsert is a draft save, so parked rows import

Payload skips validation only for a call passing `draft`, and `upsert` never
passed it — so `_status: 'draft'` alone was refused like a publish, and the
atlas importer's "re-import as a draft for an admin to fix" fallback could
never land a row that failed validation. `upsert` now takes `draft`.

The atlas importer uses it to park an inactive listing with neither a phone
nor an email (Events refuses to publish one) as a draft, rather than skipping
it, so a manager can complete it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Devindra <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Ardnived added a commit that referenced this pull request Nov 5, 2026
…it (#1079)

* feat(atlas): repeatable re-sync pipeline, with the data kept out of git

The Atlas seed data was a one-off extraction whose grooming lived only in a
committed events.json, so refreshing it meant redoing the curation by hand —
and the files carried registrant and manager personal data into this public
repository. This makes the refresh a repeatable, local pipeline.

- `pnpm atlas:sync` (seeds/atlas/sync/): fetch captures a Heroku backup of the
  legacy Atlas, restores and extracts it; build lays a grooming overlay and the
  merge decisions over it and writes the importer's input, a delta report and a
  grooming worksheet; groom applies a mechanical clean plus a hand-written
  patch; check enforces the grooming and write-contract invariants; record
  turns the groomed data into the next overlay. A rebuild reproduces the
  groomed data byte for byte.
- seeds/atlas/data/ is gitignored and removed from the tree; the CLI already
  uploads it as inlineData. Its data specs move into `check`.
- Verification floors are derived from the data on every build and ride in
  the uploaded manifest (`from-data` floors), so no refresh leaves a stale
  constant. Merge decisions move to sync/merges.ts and apply locally, so a new
  one needs no deploy.
- `pnpm seed atlas-reset` empties events, regions, users and user-submissions
  in one transaction below the Local API, refusing if a RESTRICT key appears;
  `--update` now prunes managers Atlas deleted, keeping any SahajCloud gave
  something to.
- extract.ts reads Atlas's `timestamp without time zone` columns as UTC and
  dates as dates: every timestamp was shifted by the operator's UTC offset,
  and the same dump extracted in two zones disagreed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(atlas): atlas-reset refuses while a non-Atlas client points at a region

Deleting regions nulls every client's region, and the import re-links only the
clients Atlas created, so a SahajCloud-made client would lose its region.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(atlas): import one-offs as one-offs, and keep Atlas's unmerged pairs

The preview rehearsal's clean import fell 16 events short of its floor.

- Atlas stores a single session or a concert as `type: daily` with no end, so
  the importer listed every past concert as repeating daily forever.
  `isAtlasOneOff` maps it to a schedule that does not repeat.
- `refuseDuplicateClass` (#912) shipped after production was seeded and
  refused every pair the grooming passes left unmerged on purpose (two
  managers, one slot), plus the concerts above. The seed now skips it through
  `context.skipDuplicateClassCheck`: Atlas's duplicates are decided by evidence
  in sync/merges.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(events): check a class for repeats only when its identity changes

`refuseDuplicateClass` ran on every update, so a class that already had a twin
could never be saved again — a manager's edit, or the bookkeeping write a
registration triggers, which took the registration down with it. The rehearsal
lost 10 registrations to it, and production holds such pairs today. An update
is now checked only when its region or class key moves.

The atlas importer also skips, by name, an inactive listing with neither a
phone nor an email, which Events refuses (#335's only contact is a Meetup
page), and the events floor mirrors it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(atlas): reuse an earlier upload of each event picture

Storage renames an upload, so MediaUploader's filename match never found the
earlier copy, and every run uploaded all 130 Atlas pictures again — a re-sync
keeps images through atlas-reset, so each one would have doubled them. Match
on the picture-<legacyId>- stem the renaming keeps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(seed): the seed route accepts every script, atlas-reset included

Its own hand-kept list had drifted from the CLI's. Derive it from
EXPECTED_COUNTS, which the type system makes complete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(atlas): atlas-reset shows the operator what it counted and deleted

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(seed): a draft upsert is a draft save, so parked rows import

Payload skips validation only for a call passing `draft`, and `upsert` never
passed it — so `_status: 'draft'` alone was refused like a publish, and the
atlas importer's "re-import as a draft for an admin to fix" fallback could
never land a row that failed validation. `upsert` now takes `draft`.

The atlas importer uses it to park an inactive listing with neither a phone
nor an email (Events refuses to publish one) as a draft, rather than skipping
it, so a manager can complete it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Devindra <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Can't add "Upload" block or save a page with an existing "Upload" block

1 participant