Skip to content

Commit

Permalink
Navigation Block: Avoid showing the contrast checker warning twice (#…
Browse files Browse the repository at this point in the history
…47205)

* Avoid showing the contrast checker warning twice when colors of submenus have been inherited.

* Reduce the level of nesting.
  • Loading branch information
apeatling authored Jan 17, 2023
1 parent da4ea0d commit f7052d3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,19 @@ function Navigation( {
setDetectedColor,
setDetectedBackgroundColor
);

const subMenuElement = navRef.current?.querySelector(
'[data-type="core/navigation-link"] [data-type="core/navigation-link"]'
'[data-type="core/navigation-submenu"] [data-type="core/navigation-link"]'
);
if ( subMenuElement ) {

if ( ! subMenuElement ) {
return;
}

// Only detect submenu overlay colors if they have previously been explicitly set.
// This avoids the contrast checker from reporting on inherited submenu colors and
// showing the contrast warning twice.
if ( overlayTextColor.color || overlayBackgroundColor.color ) {
detectColors(
subMenuElement,
setDetectedOverlayColor,
Expand Down

0 comments on commit f7052d3

Please sign in to comment.