-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Design Tools: Broken layout in color panel #56470
Comments
Removing this top margin on the first color gradient settings item appears to remove the gap ok but there's still a double up of the border. Until the browser redraws this panel. We might also be able to remove the top margin reset in the color hooks styles. Also, on closer inspection, it looks like the background item has its top border radii set incorrectly too until the redraw. |
This looks very glitchy 🤔
Does this happen in all browsers? |
Thanks for writing this issue up, and for coming up with reproducible steps! I noticed it while testing out appearanceTools in Classic themes (#56131) but couldn't reproduce it in a blocks-based theme, so assumed it was something particular to that feature. I can reproduce it in any theme based on your instructions now, though — it happens consistently for me with a Group block with Background color and no Text color, and it seems only on blocks with tabbed settings/styles (for me at least).
I can only reproduce it on Google Chrome and Edge on Mac. Firefox and Safari appear to be okay as far as I can tell.
TIL, thank you! That's super helpful. |
Unfortunately I haven't had much luck trying to come up with a solution. It's so weird how the Background panel item seems to think (in Chrome at least) that it's still the For a moment I was wondering if we could implement another This has me stumped for the moment, I'm sorry! |
Took a quick look, and this definitely looks like a browser glitch.
Kapture.2023-11-24.at.13.34.07.mp4The only "hint" that we could look further into is why this happens only when a color is set — what is the difference there? My gut tells me that this could be related to some race condition between react updates and re-renders. We may have to change some |
I also tested this issue on Windows OS and got the following results: Reproduced
Not Reproduced
|
Ok, so to recap:
I don't have much time to deep dive into debugging this, but if I did, this is what I'd look into at first. |
I don't fully understand these components and may cause unintended problems, but the following changes seem to solve the problem. diff --git a/packages/components/src/tools-panel/tools-panel-item/hook.ts b/packages/components/src/tools-panel/tools-panel-item/hook.ts
index 23701afdfc..816b316802 100644
--- a/packages/components/src/tools-panel/tools-panel-item/hook.ts
+++ b/packages/components/src/tools-panel/tools-panel-item/hook.ts
@@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { usePrevious } from '@wordpress/compose';
-import { useCallback, useEffect, useMemo } from '@wordpress/element';
+import { useCallback, useEffect, useLayoutEffect, useMemo } from '@wordpress/element';
/**
* Internal dependencies
@@ -59,7 +59,7 @@ export function useToolsPanelItem(
// Registering the panel item allows the panel to include it in its
// automatically generated menu and determine its initial checked status.
- useEffect( () => {
+ useLayoutEffect( () => {
if ( hasMatchingPanel && previousPanelId !== null ) {
registerPanelItem( {
hasValue: hasValueCallback, |
I haven't tested your diff, but this definitely aligns with my gut feeling that this glitch is caused by some race condition between component logic and when the component gets rendered to the DOM (this article helps to highlight the differences between the two). I don't have capacity before EOW — in terms of coordination, let me know if anyone can work on a PR with the fix, otherwise I'm happy to do it next week. |
Thanks for the debugging everyone and the suggested fix @t-hamano. I've applied Aki's patch and given it a test locally. It appears to be working well for me so I spun up #56536. I also took a quick look at the primary |
Description
If no text color has been selected, but a background color has been, when first switching to the styles tab, there'll be a gap between the text and background buttons in the color panel. As soon as something in the inspector is interacted with the gap will disappear.
A git bisect points to the style changes introduced in #55207.
cc/ @andrewserong and @ciampo
Step-by-step reproduction instructions
Note: Enabling the "Emulate a focused page" rendering option in Chrome devtools helps debug and inspect styles for this issue.
Screenshots, screen recording, code snippet
Screen.Recording.2023-11-23.at.6.56.26.pm.mp4
Environment info
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: