Skip to content
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

Navigation Menu: Show submenus only on select in the editor. #29869

Merged
merged 3 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 9 additions & 11 deletions packages/block-library/src/navigation/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,16 @@
background-color: inherit;
}

// Styles for submenu flyout
.has-child {
// Only show the flyout when the parent menu item is selected.
// Do not show it on hover.
&,
&:hover {
> .wp-block-navigation__container {
opacity: 0;
visibility: hidden;
}
// Only show the flyout on hover if the parent menu item is selected.
.wp-block-navigation:not(.is-selected):not(.has-child-selected) .has-child:hover {
> .wp-block-navigation-link__container {
opacity: 0;
visibility: hidden;
}
}

// Styles for submenu flyout
.has-child {
&.is-selected,
&.has-child-selected,
// Show the submenu list when is dragging and drag enter the list item.
Expand All @@ -65,7 +63,7 @@
}
}

// IE fix for submenu visibility on parent focus
// IE fix for submenu visibility on parent focus.
.is-editing > .wp-block-navigation__container {
visibility: visible;
opacity: 1;
Expand Down
10 changes: 7 additions & 3 deletions packages/edit-navigation/src/components/editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
margin: $grid-unit-15 auto;
}

// Adapt the layout of the Navigation and Link blocks
// Adapt the layout of the Navigation and Link blocks.
// to work better in the context of the Navigation Screen.
.wp-block-navigation {
margin: 0;
Expand All @@ -21,11 +21,15 @@
.wp-block-navigation-link {
display: block;

&.has-child:hover > .wp-block-navigation-link__container {
// Show submenus on click.
> .wp-block-navigation-link__container {
// This unsets some styles inherited from the block, meant to only show submenus on click, not hover, when inside the editor.
opacity: 1;
visibility: visible;
display: none;
}

// Fix focus outlines
// Fix focus outlines.
&.is-selected > .wp-block-navigation-link__content,
&.is-selected:hover > .wp-block-navigation-link__content {
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
Expand Down