-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline Highlight ColorPicker - Typing hex codes default to 000000, causes colorpicker to jump location #49286
Comments
I was able to reproduce this problem with the latest Gutenberg, but with slightly different results.
1ce2ce1084259524fe65eb05d3e6d91c.mp4 |
Thank you for the thorough report, @cuemarie ! Following up to @t-hamano 's reply, I think that the reason why the color popover jumps around is related to its gutenberg/packages/format-library/src/text-color/inline.js Lines 140 to 152 in b0d2478
As you can see, there's already a comment about how this value may be jumping while editing the highlight. Here's what I think may be happening:
Therefore, it doesn't look like the issue here is in the @ntsekouras , is this something that you or @ellatrix could take a look at ? |
Thank you for the analysis, @ciampo! The I suspect that the change in the return value of this hook from {Element|Range} to {Element|VirtualAnchorElement|undefined|null} might have caused the cache to not work properly. Perhaps not the ideal approach, but caching only diff --git a/packages/format-library/src/text-color/inline.js b/packages/format-library/src/text-color/inline.js
index 7a2c2f92ea..3c73984437 100644
--- a/packages/format-library/src/text-color/inline.js
+++ b/packages/format-library/src/text-color/inline.js
@@ -144,12 +144,12 @@ export default function InlineColorUI( {
it will return null, since it can't find the <mark> element within the HEX input.
This caches the last truthy value of the selection anchor reference.
*/
- const popoverAnchor = useCachedTruthy(
- useAnchor( {
- editableContentElement: contentRef.current,
- settings,
- } )
- );
+ const popoverAnchor = useAnchor( {
+ editableContentElement: contentRef.current,
+ settings,
+ } );
+ const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() );
+ popoverAnchor.getBoundingClientRect = () => cachedRect;
return (
<Popover Also, although it may not be directly related to this issue, I have discovered a problem with the initial position of the inline color popover being misaligned. If the content contains a 781da47483cd35c34025f96321b802c8.mp4 |
Thank you for looking further into it. Feel free to propose a fix, although I'll defer to folks who are more experienced with the block editor and the rich text packages to see if there's a better solution. |
Description
On a test site using WordPress 6.1.1, but Gutenberg inactive, the Inline Highlight ColorPicker moves when I try typing in a hex code, and auto-completes the code to 000000 - making it quite difficult to type in a color.
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
Screen.Capture.on.2023-03-22.at.13-14-34.mp4
Environment info
This report stems from troubleshooting on this open report: Automattic/wp-calypso#59566
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
The text was updated successfully, but these errors were encountered: