Rich Text: Make inline toolbar more reactive for proper positioning#73853
Rich Text: Make inline toolbar more reactive for proper positioning#73853ntsekouras merged 6 commits intotrunkfrom
Conversation
|
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. |
|
Should we replace the remaining |
|
Size Change: +17 B (0%) Total Size: 2.58 MB
ℹ️ View Unchanged
|
Actually I'm looking into this now and we should probably have a fresh ref to also pass in FormatEdit. That should also fix the linked issue. I'll explore and update tomorrow though. |
| */ | ||
| import { usePrevious } from '@wordpress/compose'; | ||
| import { useState, useLayoutEffect } from '@wordpress/element'; | ||
| import { getRectangleFromRange } from '@wordpress/dom'; |
There was a problem hiding this comment.
Perhaps we need a new range utility package or something, it's kind of annoying that rich text now depends on the DOM package...
There was a problem hiding this comment.
The DOM is supposed to be a small package, so I wouldn't worry too much about it 😄
7294720 to
1d2c081
Compare
|
Flaky tests detected in 5e6308b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20240462520
|
What?
Fixes: #73832
This PR solves the above issue with the Link popover (@ellatrix 's commit).
The below video from the issue demonstrates the bug:
caption.mp4
When I started exploring the linked issue I observed another bug with a stale reference of the InlineToolbar, when we remove and add again the Caption of some blocks.
This PR also makes the RichText InlineToolbar more reactive for proper positioning of the popover.
I used state to track the anchor element and a ref callback to trigger a re-render of InlineToolbar with the valid anchor.
I'm not exactly sure how why it works properly when we click for the first time, but I guess more re-renders are triggered then.
Testing Instructions for the InlineToolbar bug
Captionutil. That meansimage, audio, embed, gallery, quote, table and videoblocks.add captionbutton.Testing Instructions for Link popover bug
LinkbuttonVideos for the InlineToolbar bug
Before
before.mov
After
Screen.Recording.2025-12-09.at.8.52.39.PM.mov