Block Editor: Refactor Inserter to a function component#78766
Conversation
|
Size Change: -223 B (0%) Total Size: 8.21 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in 0e0ed8e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26621238932
|
andrewserong
left a comment
There was a problem hiding this comment.
Thanks for the ping! I like the idea of the refactor, but as far as I can tell (and from running the PR through a Claude session) it looks like this breaks the in-between inserter. I think that's that we're no longer forwarding the ref?
If I have a post with lots of paragraph blocks and hover between two paragraph blocks to reveal the in-between inserter, then scroll down the document to try to hover in other areas, I'm not able to reveal the inserter elsewhere:
2026-05-29.15.29.13.mp4
Is there a neat way to fix that (e.g. is it just that it needs a forwardRef?)
Since it exposed that bug, it'd be worth seeing if we can add a test for that, too. I'm always a tiny bit nervous refactoring some of these old components! 😄
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Good catch, @andrewserong! I've definitely missed that case. Forwarding ref shouldn't be a problem now, that we've upgraded to React 19, which supports refs for function components. cc @jsnajdr I'll push the required changes. |
|
@andrewserong, I think refs should be fixed now and match prev behavior |
andrewserong
left a comment
There was a problem hiding this comment.
That's testing nicely for me now, thanks for the update!
The new version of the file looks good to me, and I smoke tested a bunch of different usages of the inserter: list view inserter, navigation block list view inserter, inbetween inserters in different orientations, and inserter when there's only one allowed block type.
All working well as far as I can tell.
LGTM 🚀
We'll probably need to continue supporting React 18 in some packages, but Such packages can't use the new features like no- |
What?
Modernizes the
Insertercomponent in@wordpress/block-editorwith no public API or behavior changes.defaultRenderTogglefactory function is promoted to a realInserterTogglecomponent. TherenderToggleprop is preserved; when absent,<InserterToggle>renders directly.Testing Instructions
Testing Instructions for Keyboard
Same.
Use of AI Tools
Assisted by Claude.