From 2d37d9819c8a4093802565307b8a53328033b5d8 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Tue, 8 Jun 2021 10:37:36 +1000 Subject: [PATCH] Assume light theme when editor canvas background color isn't set (#32477) --- packages/block-editor/src/components/editor-styles/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/editor-styles/index.js b/packages/block-editor/src/components/editor-styles/index.js index c9ed97a81cf038..f254715e0d0ac1 100644 --- a/packages/block-editor/src/components/editor-styles/index.js +++ b/packages/block-editor/src/components/editor-styles/index.js @@ -31,7 +31,11 @@ function useDarkThemeBodyClassName( styles ) { .getComputedStyle( canvas, null ) .getPropertyValue( 'background-color' ); - if ( tinycolor( backgroundColor ).getLuminance() > 0.5 ) { + // If background is transparent, it should be treated as light color. + if ( + tinycolor( backgroundColor ).getLuminance() > 0.5 || + tinycolor( backgroundColor ).getAlpha() === 0 + ) { body.classList.remove( 'is-dark-theme' ); } else { body.classList.add( 'is-dark-theme' );