close
Skip to content

__unstableSplitSelection uses isUnmodifiedDefaultBlock, but without a role #73895

@albanyacademy

Description

@albanyacademy

Description

So there's been a bunch of stuff around splitting and attribute roles and whatnot, and a strange interaction led me to rip through the entire paste process to understand why a default block of ours was converting a pasted list into more of itself, only when the RichText input was focused.

The root cause is a line in

if ( isUnmodifiedDefaultBlock( blockA ) ) {
where the split handler checks for whether the block selected is an unmodified default block, but does not provide a role.

This gets further compounded by whether the blocks in question have transforms to or from each other. If the block is considered modified, and the blocks have valid transforms to/from, then the selected block isn't just split - the blocks being pasted in are converted as well.

I guess I'm coming at this from a view of, for example, user changes the text colour on a paragraph block and then, without anything else in the paragraph at all but with the focus inside it, pastes in an HTML list.
The result is the list items converted to paragraphs, but with the top and bottom lines using the colour.

Image

As you can see, its kinda weird!

There's a couple ways this could be interpreted:

  1. The block had no content, so it should have been replaced with a list.
    • with an optional "should the list also be pink", because the user did do something here. there's just nothing to split, so why use split logic?
  2. The user made a conscious change, so they probably want it to be a paragraph. In which case, why aren't all the lines pink?

And probably more besides, but that's what I'm stuck on.

Step-by-step reproduction instructions

  1. blank post
  2. copy an HTML list
  3. in the default paragraph block, change text colour to pink.
  4. then, with the paragraph block selected and the cursor blinky blinky, paste.
  5. see that list items are all converted to paragraphs, but only the first and last block have a pink colour.

Screenshots, screen recording, code snippet

No response

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

[Feature] Writing FlowBlock selection, navigation, splitting, merging, deletion...[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions