WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.34k stars 4.13k forks source link

6.6: changed behaviour on pressing Enter on a selected block #65274

Open elzadj opened 6 days ago

elzadj commented 6 days ago

Description

Hi everyone!

We noticed that hitting Enter on our custom blocks inserts an empty paragraph since the 6.6.2 6.6 update. Before 6.6.2 6.6 it was inserting a copy of the same block.

We suspect that this has something to do with that fix: https://github.com/WordPress/gutenberg/pull/64992/files

The block in question: https://github.com/maxi-blocks/maxi-blocks/tree/master/src/blocks/text-maxi

Can you advise something, please? Maybe we can make some changes to revert it without rolling back to 6.5.5? Something for splitting the block, possibly?

Note: Adding support for "splitting": doesn't help.

Thanks!

Step-by-step reproduction instructions

  1. https://wordpress.org/plugins/maxi-blocks/
  2. Add a Container + Text inside a Column
  3. Press Enter on the Text, Column, Row. Or check the videos below.

Screenshots, screen recording, code snippet

Before 6.6:

screencast-maxiblocks.com-2024.09.12-12_54_32.webm

On 6.6.2:

screencast-wordpress.local-2024.09.12-13_23_08 (1).webm

Environment info

WordPress 6.6.2 PHP 8.3

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

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

Mamaduka commented 6 days ago

cc @stokesman

stokesman commented 6 days ago

So far I’m not able to reproduce the desired behavior on 6.6.1. I find that, from a Text Maxi block, pressing Enter inserts a core paragraph, whether the the block is nested in a Container Maxi block or not. That was testing MaxiBlocks 1.9.5.

I notice in the "Before 6.6.2" screen recording there seem to be more plugins enabled than in the other screen recording. Also I don’t see the Document Bar. It has been around since before 6.6.1 so it makes me wonder what the actual version of WP is in that screen recording.

document-bar

☝️ Document Bar for clarity’s sake.

We suspect that this has something to do with that fix: https://github.com/WordPress/gutenberg/pull/64992/files

It doesn’t seem likely to be related. Those changes and that whole file are solely involved with handling a mouse event and I don’t see how that would affect this keyboard behavior.

Mamaduka commented 4 days ago

This could be related to the onSplit callback deprecation in WP 6.6. I see that the Text Moxi block is using it.

This was mentioned in dev note as well.

elzadj commented 2 days ago

This could be related to the onSplit callback deprecation in WP 6.6. I see that the Text Moxi block is using it.

This was mentioned in dev note as well.

Yes, it definitely started from 6.6, and is connected to onSplit deprecation.

But it seems like we can't re-create the behaviour we had before 6.6? We want the block to support splitting, but we also want to create a new empty Text block when we hit Enter at the end of it. It looks like creating an empty paragraph is the default now , right?

It's also mentioned that onSplit should continue to work, but seems like it's not the case any more.

Is there any alternative to onSplit?