Skip to content

Added custom field editing to member details - #29405

Merged
rob-ghost merged 3 commits into
mainfrom
feat/member-custom-field-editor
Jul 17, 2026
Merged

rob-ghost merged 3 commits into
mainfrom
feat/member-custom-field-editor

Conversation

@renatoworks

Copy link
Copy Markdown
Contributor

Describe the problem you are solving

Custom field definitions shipped in Settings (BER-3785), but values were only reachable over the API — nothing in the admin let a person see or change what a member's fields hold. This PR adds the value side to the React member details screen: the fields defined in Settings appear against each member as a read-only record, and each one is editable through a focused per-field editor. Behind the membersCustomFields flag (and the screen itself behind memberDetailsReact).

Depends on #29373 (member custom field values API) — this PR consumes its contract and stays draft until it lands. With the flag on but no values API, the member read's include=custom_fields is rejected; with the flag off, requests are byte-identical to today.

Changelog for devs

  • Added a Custom fields section to the React member detail screen: read-only value rows (addresses formatted as one line), whole-row click opens a per-field modal editor with its own immediate Save — a single-key merge patch over the member PUT (null clears)
  • Added client-side validation against the shared @tryghost/custom-field-types schemas — the same schemas the server enforces — with plain-English messages per the writing guide; a server 422 naming a field via its property path pins the message to the exact input as a backstop
  • Added a dirty-dismissal guard to the editor: outside click and Escape are no-ops once a value has been typed, Cancel is the only explicit discard
  • Added custom_fields to the framework's Member/EditMemberData types; the member PUT requests include=custom_fields only when the payload writes values
  • Added acceptance coverage (8 specs: rows, editor save/clear/cancel, validation, 422 pinning, dismissal guard, empty-state) plus unit coverage for the normalization/payload/validation helpers

Changelog for customers

  • Added the ability to view and edit a member's custom field values on the member details screen (behind the membersCustomFields flag)

Notes

  • Why view-first instead of inline inputs: the member screen is a record, not a form — admins read this data constantly and change it rarely. We built the inline version first and rejected it: hot inputs put accidental edits one keystroke away, made "which Save saves what" (page vs fields) genuinely confusing, and buried the values in control chrome. The read-only record is more predictable and easier to scan — the value is the content, not the input state — and the per-field editor gives one field, one Save, one outcome, with the API's merge semantics making isolated saves safe by design.
  • Rows follow the admin's existing list language: hover tint with fading dividers (settings lists), row-click with revealed pencil (tags list). Values stay text-selectable so addresses can be copied.
  • Existing members only — the create contract doesn't take values yet.

Technical debt

  • Country is a bare 2-letter code input; a proper country select is a follow-up
  • Server 422 context renders verbatim in the (rare) backstop path — humanizing that copy is a server-side follow-up, flagged separately

PR Scope (mark all that apply)

  • Improves the user experience
  • Enhances the readability of our code
  • Simplifies the maintenance of our software
  • Fixes a bug
  • Provide a core layer to allow one of the points above

Checklist before requesting a review (mark all that apply)

  • I have performed a self-review of my code
  • It's simple enough
  • The PR is not extensive
  • It includes documentation
  • I have added thorough tests.
  • Do we need to implement analytics?
  • Will this be part of a product update? If yes, please write one phrase about this update.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a965f298-2696-441d-bcfd-49e1bbfa8071

📥 Commits

Reviewing files that changed from the base of the PR and between 1687ebf and ea3fdc6.

📒 Files selected for processing (5)
  • e2e/helpers/pages/admin/members/member-details-page.ts
  • e2e/helpers/pages/admin/settings/sections/custom-fields-section.ts
  • e2e/helpers/pages/admin/settings/sections/index.ts
  • e2e/helpers/pages/admin/settings/settings-page.ts
  • e2e/tests/admin/members/member-custom-fields.test.ts

Walkthrough

Adds feature-flagged custom fields to the member detail page with read-only display and per-field editing for scalar and address values. It updates API types, normalization, formatting, validation, merge-patch saving, clearing, and server-error handling. Unit, browser acceptance, and end-to-end tests cover the editing flows and feature visibility.

Possibly related PRs

Suggested reviewers: 9larsons, rob-ghost, 9larsons

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding custom field editing on member details.
Description check ✅ Passed The description accurately explains the feature, scope, and dependencies of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/member-custom-field-editor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…creen

ref https://linear.app/ghost/issue/BER-3800/edit-custom-field-values-on-the-member-details-screen

Why this shape — the member detail screen is a record, not a form. An
admin's daily relationship to a member's data is reading it; editing is
the rare, deliberate act. The design follows from that:

- values render as a read-only record with a per-field editor, not as
  inline form inputs: always-hot inputs invert the read/edit priority,
  put an accidental edit one keystroke away, and drown the values in
  control chrome (an earlier inline version of this feature was built
  and rejected for exactly this — see feat/member-custom-field-values
  for the record)
- each field saves individually through its own modal with its own Save:
  one field, one save, one outcome. Inline editing shared the page's
  Save and made "which Save saves what" genuinely confusing; the API's
  merge semantics (only the sent key is touched, null clears) make
  isolated single-key saves safe by design
- a dirty editor refuses casual dismissal (outside click, Escape) —
  Cancel is the only explicit discard, so a typed value can never be
  lost to a stray click; pristine editors dismiss freely
- values validate client-side against the shared
  @tryghost/custom-field-types schemas — the same schemas the server
  enforces — with human copy per the writing guide; a server 422 naming
  a field via its property path pins the message to the exact input as
  a backstop
- rows speak the admin's existing list language: hover tint with fading
  dividers (settings lists), whole-row click with a revealed pencil
  (tags list); values stay selectable so addresses can be copied — a
  selection release doesn't open the editor
- behind membersCustomFields; existing members only (the create
  contract doesn't take values yet, and a value can't exist before its
  member does)
@rob-ghost
rob-ghost force-pushed the feat/member-custom-field-editor branch from 3601181 to ad1f917 Compare July 17, 2026 10:34
@nx-cloud

nx-cloud Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 1687ebf

Command Status Duration Result
nx run @tryghost/admin:test:acceptance ✅ Succeeded 5m 28s View ↗
nx run-many -t test:unit -p @tryghost/admin-x-f... ✅ Succeeded 2m 38s View ↗
nx run @tryghost/activitypub:test:acceptance ✅ Succeeded 36s View ↗
nx run ghost-admin:test ✅ Succeeded 4s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded <1s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded 1s View ↗
nx run-many -t lint -p @tryghost/admin-x-framew... ✅ Succeeded 8s View ↗
nx run @tryghost/admin:build ✅ Succeeded 5s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-17 11:34:34 UTC

@codecov

codecov Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.30%. Comparing base (d8cc811) to head (ea3fdc6).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #29405   +/-   ##
=======================================
  Coverage   74.30%   74.30%           
=======================================
  Files        1595     1595           
  Lines      139505   139505           
  Branches    16946    16946           
=======================================
+ Hits       103657   103659    +2     
+ Misses      34831    34830    -1     
+ Partials     1017     1016    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rob-ghost
rob-ghost marked this pull request as ready for review July 17, 2026 10:48

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/admin/src/members/detail/member-custom-fields-field.tsx`:
- Around line 168-213: Update the dialog dismissal handling in the member
custom-field editor so it cannot close while editMutation.isPending is true.
Apply this guard to Cancel, onOpenChange, and the Escape/outside interaction
handlers, while preserving the existing isDirty prevention behavior for
non-pending edits.
- Around line 31-33: The ErrorMessage component currently renders validation
text without accessibility semantics. Update ErrorMessage to expose each
non-empty message as an assertive live region by adding role="alert" to the
rendered paragraph, while preserving its existing conditional rendering and
styling.

In `@apps/admin/src/members/detail/member-detail-edit.ts`:
- Around line 270-295: Localize the complete custom-field editing flow: in
apps/admin/src/members/detail/member-detail-edit.ts:270-295, use Admin
translations for validation messages and interpolate the character limit; in
apps/admin/src/members/detail/member-custom-fields-field.tsx:22-29, translate
address labels; at :154-162, translate toast messages with {fieldName}; at
:186-213, translate modal controls and status copy; and at :250-304, translate
the section heading and dynamic edit ARIA label. Add all corresponding entries
to packages/i18n/locales/en/ghost.json, using {variable} interpolation syntax
for dynamic values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f4910273-7992-4dba-8a92-e1940543695b

📥 Commits

Reviewing files that changed from the base of the PR and between d8cc811 and ad1f917.

📒 Files selected for processing (9)
  • apps/admin-x-framework/src/api/member-custom-fields.ts
  • apps/admin-x-framework/src/api/members.ts
  • apps/admin/src/members/detail/member-custom-fields-field.tsx
  • apps/admin/src/members/detail/member-detail-custom-fields.acceptance.test.tsx
  • apps/admin/src/members/detail/member-detail-edit.test.ts
  • apps/admin/src/members/detail/member-detail-edit.ts
  • apps/admin/src/members/detail/member-detail-format.test.ts
  • apps/admin/src/members/detail/member-detail-format.ts
  • apps/admin/src/members/detail/member-detail.tsx

Guards against no-op saves that would fire member.edited for an unmoved
value, blocks dismissing or double-saving while a PUT is in flight, and
gives screen readers the failure and the current value. Over-long required
address sub-fields now report a length error instead of the missing-value copy.
@rob-ghost
rob-ghost force-pushed the feat/member-custom-field-editor branch from ad1f917 to 1687ebf Compare July 17, 2026 11:19
Component acceptance tests mock the API, leaving the cross-surface
round-trip unverified: a field defined in Settings must appear on the
member detail screen, accept a value through its own editor, and persist
across a reload. This pins that settings -> member-detail -> server flow
end-to-end, adding the CustomFieldsSection page object and member detail
custom-field helpers to drive it.
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.

2 participants