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

Nav menu items styling not as expected #26

Closed
bobbingwide opened this issue Nov 9, 2020 · 14 comments
Closed

Nav menu items styling not as expected #26

bobbingwide opened this issue Nov 9, 2020 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@bobbingwide
Copy link
Owner

When I started styling the nav menu I copied the CSS from genesis-a2z. The screenshot.png I took on 28th October showed the white space.
When I updated to Gutenberg 9.2.2 I noticed the space between menu items disappeared.
This is because there is no longer a blank space between list items.
This can easily be demonstrated using the the code inspector.
In this screen capture, from the genesis-a2z theme, I removed the blank space between a couple of items.
image

Requirement

Some spacing between the menu items.

Proposed solution

In order to regain the blank space I'll either need to change the CSS, or adjust the markup.
It makes more sense to use CSS.

@bobbingwide bobbingwide added the bug Something isn't working label Nov 9, 2020
@bobbingwide bobbingwide self-assigned this Nov 9, 2020
bobbingwide added a commit that referenced this issue Nov 10, 2020
@bobbingwide
Copy link
Owner Author

bobbingwide commented Mar 19, 2021

It's happened again with WordPress 5.7 and Gutenberg 10.2.1.
But I can't rule out stupidity on my part.
Time to investigate. From blocks.wp.a2z. This is the menu in the header. The footer's the same.
image

The change occurred between 10.1.1 and 10.2.0
In the previous fix I changed

.wp-block-navigation li {
    margin-right: 10px;
}

to

.wp-block-navigation-link {
    padding-right: 4px;
}

In the change for 10.2.0 there's some new CSS that I need to check out.

.wp-block-navigation ul li{list-style:none;margin:0;padding:0}

Also, some CSS which appears to target the same class twice.

.wp-block-navigation-link.wp-block-navigation-link { margin: 0; }

@bobbingwide
Copy link
Owner Author

bobbingwide commented Mar 21, 2021

It would appear that I didn't need to raise the issue. I just needed to find the right CSS, which for Fizzie is

.wp-block-navigation ul li {
   padding-right: 4px;
}

@bobbingwide
Copy link
Owner Author

bobbingwide commented Apr 7, 2021

With Gutenberg 10.3.1 the menu spacing and colours have changed again

10.0.2, 10.1.0, 10.1.1, 10.2.0, 10.2.1

image

10.3.0, 10.3.1
image

To fix the spacing I have to remove the right margin that had been added to the inline CSS.

.wp-block-navigation .wp-block-navigation-link {
    margin-right: 0em;
}

To change the link colors I have to override the color: inherit on the links.

.wp-block-navigation .wp-block-navigation-link__content,
.wp-block-navigation .wp-block-pages-list__item__link {
    color: #ffffff;
}

@bobbingwide
Copy link
Owner Author

In 10.4.0 the colours are wrong on the single.html page.
The foreground colour's supposed to be white, not black.
For other templates the colours are as expected.
image

@bobbingwide
Copy link
Owner Author

In 10.6.0-rc.1 the menus have changed again
image

Looks like all my padding's gone.
Now to find what's changed

@bobbingwide bobbingwide changed the title Nav menu items no longer separated by white space Nav menu items styling not as expected Jun 1, 2021
@bobbingwide
Copy link
Owner Author

With 10.7.1, a partly completed theme.json and an unchanged style.css the nav menu currently looks like this.
image

Note: I also have to restyle the 3 block grid, for blocks, plugins and themes.

@bobbingwide
Copy link
Owner Author

I discovered that if you set the background color then it gives a certain amount of padding.
I changed the header and header-menu template parts, and style.css to change the font size, weight and colors.
The top menu is better now. I happy to leave the bottom menu as is.

image

@bobbingwide
Copy link
Owner Author

bobbingwide commented Jan 10, 2022

With Gutenberg 12.3.0 and/or WordPress 5.9-RC1 the problems are:

  • current menu item no longer being highlighted
  • colours don't change on hover
  • the footer menu doesn't have any padding; left and right

The current menu item highlighting worked fine with Gutenberg 11.8.0, which needs WordPress 5.8
The colour changing worked fine with Gutenberg 11.7.0

@bobbingwide
Copy link
Owner Author

Tabulating the above

GB WP 5.9 WP 5.8.2 Current menu highlight Hover?
12.3.0 Y Y N N
12.2.0 Y Y N N
12.1.0 Y Y N N
12.0.0 Y Y N N
11.9.0 Y Y N N
11.8.0 N Y Y N
11.7.0 N Y Y Y

@bobbingwide
Copy link
Owner Author

I made some changes to includes/navigation-link.php and style.css to implement a new solution that works for Gutenberg 12.3.0 with WordPress 5.9-RC1.
However, none of the override logic works when Gutenberg is not activated.
Some more work is needed to support WordPress 5.9 on its own.

One solution is to use the official WordPress solution, which is to change the links so that the id attribute is set.

@bobbingwide
Copy link
Owner Author

I've fixed the display so that the top menu looks good with:

  • Gutenberg 12.3.0 activated
  • or WordPress 5.9-RC1 and Gutenberg deactivated

image

This capture shows the menu when

  • Blocks is the current menu item - extra padding on the RHS
  • Plugins menu item has focus - border outline
  • The mouse is hovering over Themes - white background

@bobbingwide
Copy link
Owner Author

Problems:

  • The footer menu's not properly styled.
    • Padding missing
    • Font too large
  • The Home item has gone missing.

image

In blocks.wp-a2z.org it currently looks like this
image

Partial explanation for Home item has gone missing

  • Gutenberg is deactivated
  • The core/home-link block is not supported in WordPress 5.9-RC1

But this doesn't seem right to me since the Home link was added in Gutenberg 10.7.0

@bobbingwide
Copy link
Owner Author

bobbingwide commented Mar 12, 2023

Latest commit delivered in Fizzie v1.2.0 still works with WordPress 6.2-RC1 & Gutenberg 15.3.1
On the home page, in the footer menu the styling doesn't match the header
image

image

The styling for the current menu item isn't being applied since it doesn't have
class has-current-menu-item-background-color.

.wp-block-navigation .wp-block-navigation-link__content:hover, 
.wp-block-navigation .wp-block-navigation-item__content:hover, 
.wp-block-navigation .current-menu-item > a, 
.wp-block-navigation .has-current-menu-item-background-color > a {
    background: #ffffff;
    border: 1px solid var(--wp--preset--color--woo-deep-purple, #baba54 );
    margin: 0 auto;
    color: #792B0C;
    text-decoration: none;

This is because the header-menu template part uses <!-- wp:navigation-link {"label":"Home","url":"https://s.b/wp56/"} /-->
but the menu item in the footer-menu template part is created using <!-- wp:home-link {"label":"Home"} /-->
I haven't written logic to override the home-link block.

@bobbingwide
Copy link
Owner Author

Closing this for now. It can be reopened when the time comes that I want to change the styling of the menu in the footer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant