Directory

Return AttributeKey as number · Issue #58996 · WordPress/gutenberg · GitHub
Skip to content
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

Return AttributeKey as number #58996

Closed
akasunil opened this issue Feb 14, 2024 · 4 comments · Fixed by #59056
Closed

Return AttributeKey as number #58996

akasunil opened this issue Feb 14, 2024 · 4 comments · Fixed by #59056
Assignees
Labels
[Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended

Comments

@akasunil
Copy link
Contributor

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

@akasunil akasunil added the [Type] Bug An existing feature does not function as intended label Feb 14, 2024
@Mamaduka Mamaduka added Needs Technical Feedback Needs testing from a developer perspective. [Package] Block editor /packages/block-editor and removed [Type] Bug An existing feature does not function as intended labels Feb 14, 2024
@talldan
Copy link
Contributor

talldan commented Feb 14, 2024

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.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Feb 15, 2024
@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Package] Block library /packages/block-library and removed [Status] In Progress Tracking issues with work in progress Needs Technical Feedback Needs testing from a developer perspective. [Package] Block editor /packages/block-editor labels Mar 21, 2024
@gziolo
Copy link
Member

gziolo commented Mar 21, 2024

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

@Mamaduka
Copy link
Member

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

@jsnajdr
Copy link
Member

jsnajdr commented Mar 21, 2024

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
Labels
[Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants