You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
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.
Activity
talldan commentedon Feb 14, 2024
I believe it returns the
identifierprop set on the RichText. The file block doesn't have anidentifierset, 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.
gziolo commentedon Mar 21, 2024
@ellatrix, should we make
identifiera required prop when usingRichTextin the context of block edit?Mamaduka commentedon Mar 21, 2024
@gziolo, I think it's only "required' when RichText is bound to the attribute. @jsnajdr added the documentation in #60036.
jsnajdr commentedon Mar 21, 2024
Site Title and Site Tagline are examples of blocks where there's no reasonable
identifierfor theRichText. The editable field is bound to theeditEntityRecord( 'root', 'site' )entity, not to a block attribute.It's bit of an unsolved problem what the
identifiershould be in this case, and what the Redux state (getSelectionStart()) should contain asattributeKey. I posted a comment about it (#58913 (comment)) demonstrating a few little bugs that are caused by this.