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

Add page-list to blocks that needs list item wrapper #61482

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

saulirajala
Copy link

@saulirajala saulirajala commented May 8, 2024

What?

Wrap core/page-list with list item wrapper when its innerBlock of core/navigation

Closes #60500

Why?

Fix for #60500. When you use page-list -block as inner block of navigation block, there will be invalid html code <ul><ul><li></li></ul></ul> -structure in the frontend.

Testing Instructions

  1. Check Gutenberg PR Preview
  2. Inspect the navigation in header. It has <ul><li><ul><li></li></ul></li></ul> -structure, which is valid html

Screenshots

Before
Screenshot 2024-05-08 at 13 31 30

After
Screenshot 2024-05-08 at 13 31 10

@saulirajala saulirajala requested a review from ajitbohra as a code owner May 8, 2024 10:19
Copy link

github-actions bot commented May 8, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: saulirajala <saulirajala@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

github-actions bot commented May 8, 2024

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @saulirajala! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label May 8, 2024
@saulirajala
Copy link
Author

Hey @ajitbohra 👋 Any change to get this fixed before WP6.7 release?

@getdave getdave added [Type] Bug An existing feature does not function as intended [Block] Navigation Affects the Navigation Block labels Nov 20, 2024
@getdave
Copy link
Contributor

getdave commented Nov 20, 2024

@saulirajala Thanks you for the PR and for your diligence in updating it in line with changes for WP 6.7. I've requested reviews from a few folk familiar with the block so hopefully we can get some reviews soon.

@talldan
Copy link
Contributor

talldan commented Nov 25, 2024

Thanks for making the PR, sorry for the delay in anyone getting back to you. In terms of the solution, I think it might be better to go the other way, and remove the <ul> from page lists when in a navigation block.

Page List's use case in the navigation block is a quick way to add a set of navigation links, and any other individual navigation links added alongside it should appear visually as the same set of links, and also be that way in terms of the HTML hierarchy. (IMO)

It looks like there's precedence for this, as if you add Page List in a submenu alongside a custom link, it already works that way, the <ul> tag is removed from page list. It's controlled by this isNested attribute:

$is_nested = $attributes['isNested'];

Here's where it's determined. It might be a simple adjustment to make this work:

const blockParents = getBlockParentsByBlockName(
clientId,
'core/navigation-submenu',
true
);
const navigationBlockParents = getBlockParentsByBlockName(
clientId,
'core/navigation',
true
);
return {
isNested: blockParents.length > 0,
isChildOfNavigation: navigationBlockParents.length > 0,
hasSelectedChild: hasSelectedInnerBlock( clientId, true ),
hasDraggedChild: hasDraggedInnerBlock( clientId, true ),
parentClientId: navigationBlockParents[ 0 ],
};

@draganescu's PR #46414 implemented that, so Andrei might have some advice.

@getdave
Copy link
Contributor

getdave commented Dec 3, 2024

@saulirajala Do you feel you would have time to make the adjustments here? No rush but wanted to check as it's on my radar to keep track of. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Page List block inside navigation block will result invalid html
4 participants