-
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
Fix: Custom color formatter may end up "bouncing" #20612
Fix: Custom color formatter may end up "bouncing" #20612
Conversation
Size Change: -22 B (0%) Total Size: 865 kB
ℹ️ View Unchanged
|
}, [ isActive, addingColor, value.start, value.end ] ); | ||
}, [] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which of these is changing to cause the cache to be bust and recompute the anchor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda seems like the anchor calculation should be testing whether it's within the popover, and aborting if so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like these values shouldn't be changing in the first place, which is something we should be addressing higher up than in this component itself. Notably, I observe that value.start
and value.end
each change to undefined
at some points, which I don't think would ever be expected while this component is mounted.
}, [ isActive, addingColor, value.start, value.end ] ); | ||
}, [] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like these values shouldn't be changing in the first place, which is something we should be addressing higher up than in this component itself. Notably, I observe that value.start
and value.end
each change to undefined
at some points, which I don't think would ever be expected while this component is mounted.
Hi @aduth, what this PR does is making sure anchorRect is never recomputed. I think it is a safe change because there is no relevant action one could take that may require the popover to change position without first closing the popover (e.g: one can not change the start and end while the popover is open). |
Fixes: https://core.trac.wordpress.org/ticket/49568
How has this been tested?
I added a paragraph with some text.
I opened the formater menu and applied a custom text color to the paragraph using the mouse.
I manually applied the "red" color (I verified that the popover did not start moving randomly around the screen).
I selected another part of the text in the paragraph I applied a custom color and verified the popovers positions for both parts of the paragraph with colors are correct close to the part of text they refer to.