payloadcms / payloadcms/payload
Function-based admin.hidden invalidates existing Lexical block relationships
@AlessioGr is already working on this.
Since Sep 11, 2026.
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug
BlocksFeature applies applyBaseFilterToFields to relationship fields inside Lexical blocks. The injected filterOptions calls the target collection's admin.hidden function and returns false when that function returns true for the current user.
Payload's relationship validation interprets filterOptions: false as meaning that every selected ID is invalid. As a result, a user with read access to the target collection cannot save an otherwise valid document containing an already-selected relationship. Saving without changing the relationship fails with Invalid selections.
This couples admin UI visibility to persisted relationship validity. It is also inconsistent with static configuration: the injected filter checks function-based admin.hidden, but does not check admin.hidden: true.
The relevant path is:
@payloadcms/richtext-lexicalrecursively wraps relationships insideBlocksFeatureblocks.- The wrapper returns
falsewhenadmin.hidden({ user })returnstrue. validateFilterOptionsadds the relation tofalseCollectionsand rejects the existing ID.
Expected behavior: hiding a collection from a user's admin UI should not invalidate an existing relationship that the same user is authorized to read. At minimum, saving an untouched relationship should not fail validation because of admin.hidden.
This behavior appears to originate from #14985, which added applyBaseFilterToFields for Lexical blocks. The same function-based hidden check also exists in the Lexical internal-link relationship filter, so that path may be affected as well.
Link to the code that reproduces this issue
https://github.com/jenslys/payload/tree/21b39fd4c0678873ea2d3ed91e09980ebfa42582/test/_community
The reproduction is based directly on the v3.87.0 tag.
Reproduction Steps
-
Check out the reproduction commit:
git clone --branch repro/lexical-admin-hidden-validation https://github.com/jenslys/payload.git cd payload -
Install dependencies and start the
_communityfixture:pnpm install pnpm exec cross-env PAYLOAD_DATABASE=sqlite pnpm dev _community -
Open the admin panel and use the configured auto-login user.
-
Open Reproduction Posts and edit Saving this post fails. The seeded Lexical block already references Existing relationship target.
-
Click Save without changing anything.
-
The save fails with an
Invalid selectionsvalidation error onrelatedItem. -
Change
hidden: ({ user }) => Boolean(user)tohidden: false, restart, and repeat. The same post can now be saved.
The logged-in user retains normal read access to hidden-items; only admin.hidden hides the collection.
The reproduction also contains an integration test expressing the expected behavior. It was run with:
pnpm exec cross-env PAYLOAD_DATABASE=sqlite pnpm test:int _community
On Payload 3.87.0 it fails with:
AssertionError: expected 400 to be 200
Content > Related Item: This field has the following invalid selections: 1
Which area(s) are affected?
- plugin: richtext-lexical
- area: core
- area: ui
Environment Info
Payload: 3.87.0
@payloadcms/richtext-lexical: 3.87.0
Next.js: 16.3.0
React: 19.2.7
React DOM: 19.2.7
Node.js: 24.13.0
Package manager: pnpm (upstream reproduction), Bun 1.3.6 (original application)
Database: PostgreSQL in the original application; SQLite in the public reproduction
Operating system: macOS Darwin 25.5.0 arm64
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.