Skip to content

Blocks Field - Components docs inaccurate #12112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
damnsamn opened this issue Apr 15, 2025 · 1 comment · May be fixed by #12135
Open

Blocks Field - Components docs inaccurate #12112

damnsamn opened this issue Apr 15, 2025 · 1 comment · May be fixed by #12135
Labels
created-by: Contributor documentation Improvements or additions to documentation

Comments

@damnsamn
Copy link
Contributor

Documentation Issue

The Blocks Fields page in the docs lists a RowLabel component which is not exported with the BlocksField types. Presumably this was just copied across from the Array Field docs in error, but it does speak to an unmet need with the Blocks field. I think it should have a RowLabel component (or equivalent) to replace blockName. See this discussion #4648

The relevant erroneous section:

Row Label

'use client'

import { useRowLabel } from '@payloadcms/ui'

export const BlockRowLabel = () => {
  const { data, rowNumber } = useRowLabel<{ title?: string }>()

  const customLabel = `${data.type} ${String(rowNumber).padStart(2, '0')} `

  return <div>Custom Label: {customLabel}</div>
}
@damnsamn damnsamn added the documentation Improvements or additions to documentation label Apr 15, 2025
@akhrarovsaid akhrarovsaid linked a pull request Apr 16, 2025 that will close this issue
@akhrarovsaid
Copy link
Contributor

Hey @damnsamn

So, the Blocks field itself exposes a Label component which allows you to define your own label. However, the docs seem to omit the fact that each Block itself can also have a Label component via admin.components.Label defined within the block config. You can add your row label here.

Demo:
Image

I think it would be nice to allow users to generate block names from a function defined in config though, so I've addressed the feature request in your issue here: #12135. I've also gone ahead and cleaned up the docs around Block row labels with a more thorough example which should address your issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
created-by: Contributor documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants