WordPress / gutenberg

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

Quick inserter: hard to initiate quick inserter after a few times using it #65106

Closed annezazu closed 4 days ago

annezazu commented 1 week ago

Using WordPress 6.6.2 and Gutenberg 19.1 in a playground instance, I noticed that, after a first few times, the quick inserter suddenly becomes very hard to initiate. I can't quite understand why but here's a longer video showing how suddenly the same areas where I could use the quick inserter no longer cause it to appear:

https://github.com/user-attachments/assets/6bac378a-9786-47da-87e9-6f82a6b3005a

I can reliably replicate it using TT4 and just clicking around and trying to get it to appear.

Mamaduka commented 1 week ago

Thanks, @annezazu! This is an interesting issue.

Did you also notice any performance degradation? We have some reports related to Inserter + Pattern performance, and I wonder if they are related. See: #64732.

A possible fix will ship with Gutenberg 19.2 - #64902.

annezazu commented 6 days ago

I didn’t notice anything with performance when I was clicking around! It could be that that’s the underlying cause though but it wasn’t discernible to me.

Mamaduka commented 6 days ago

I can also reproduce the issue on the Gutenberg trunk, but I'm having trouble finding a consistent way to do it.

I tracked down the bug to the useInBetweenInserter hook. The openRef.current is set to true permanently, which prevents any other in-between inserters from displaying. Unfortunately, I'm still not sure what is causing this behavior.

https://github.com/WordPress/gutenberg/blob/cc133bfae5fe1b575e754fbcd71ff3505a448a35/packages/block-editor/src/components/block-list/use-in-between-inserter.js#L45-L49

Update: I think I found a consistent way to reproduce the bug. It looks like the onSelectOrClose is never called when moving focus to a different block on canvas.

  1. Create a page.
  2. Add a couple of paragraphs.
  3. Open in-between inserter.
  4. Move the focus to a different block without closing the inserter.
  5. Notice that the inserter no longer appears when hovering between the blocks.

Screencast

https://github.com/user-attachments/assets/72570272-d33d-44aa-9410-804a05556208

Mamaduka commented 4 days ago

This is fixed on the trunk. See: #65208.