Skip to content

Return AttributeKey as number  #58996

Closed

Description

@akasunil

Description

getSelectionStart() function of block editor return attributeKey as number in Gutenberg file block. is it expected behavior? Shouldn’t it return selected attribute key from available attributes of file block instead of number ? what does this number represent ?

Step-by-step reproduction instructions

Execute wp.data.select("core/block-editor").getSelectionStart() after selecting file block in editor

Screenshots, screen recording, code snippet

CleanShot 2024-02-14 at 11 40 34@2x

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Activity

  1. added
    [Type] Bug
    on Feb 14, 2024
  2. added
    Needs Technical Feedback
    [Package] Block editor
    and removed
    [Type] Bug
    on Feb 14, 2024
  3. talldan commented on Feb 14, 2024

    @talldan
    Contributor

    I believe it returns the identifier prop set on the RichText. The file block doesn't have an identifier set, so a numeric id seems to be used instead.

    It could be fixed by adding identifiers in the block, which I think might be best practice when a block contains more than one RichText element.

  4. added
    [Status] In Progress
    on Feb 15, 2024
  5. added
    [Type] Bug
    [Package] Block library
    and removed
    [Status] In Progress
    Needs Technical Feedback
    [Package] Block editor
    on Mar 21, 2024
  6. gziolo commented on Mar 21, 2024

    @gziolo
    Member

    @ellatrix, should we make identifier a required prop when using RichText in the context of block edit?

  7. Mamaduka commented on Mar 21, 2024

    @Mamaduka
    Member

    @gziolo, I think it's only "required' when RichText is bound to the attribute. @jsnajdr added the documentation in #60036.

  8. jsnajdr commented on Mar 21, 2024

    @jsnajdr
    Member

    Site Title and Site Tagline are examples of blocks where there's no reasonable identifier for the RichText. The editable field is bound to the editEntityRecord( 'root', 'site' ) entity, not to a block attribute.

    It's bit of an unsolved problem what the identifier should be in this case, and what the Redux state (getSelectionStart()) should contain as attributeKey. I posted a comment about it (#58913 (comment)) demonstrating a few little bugs that are caused by this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Package] Block library[Type] Bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions