Skip to content

Block reference content disappears when collection-level update permission is false #13569

@rilrom

Description

@rilrom

Describe the Bug

When a project is using blockReferences and collection-level update permissions are set to false, the block content disappears instead of being read-only.

This issue does not occur when using blocks.

I've narrowed it down to the below code in the BlockRow component:

if (permissions === true) {
    blockPermissions = true
  } else {
    const permissionsBlockSpecific = permissions?.blocks?.[block.slug]
    if (permissionsBlockSpecific === true) {
      blockPermissions = true
    } else {
      blockPermissions = permissionsBlockSpecific?.fields
    }
  }

When using blocks, permissions?.blocks is { title: { fields: [Object], create: true, read: true } } however when using blockReferences, permissions?.blocks is true, which leaves blockPermissions set to undefined.

Link to the code that reproduces this issue

https://github.com/riley-pearce-airteam/eclipse-update-permission-blocks-bug

Reproduction Steps

  1. Create a new post with a title block.
  2. Uncomment update: () => false for the posts collection.
  3. Notice that the blocks content disappears, it should be visible but not editable instead.

Which area(s) are affected? (Select all that apply)

area: ui

Environment Info

Payload: v3.53.0
Next: 15.5.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions