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

Transform page list to list #69116

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

Conversation

benazeer-ben
Copy link
Contributor

What?

Fixes #44458

Why?

Currently Page list block has no transform option for list block.

How?

Added list block transformation to Page list block.

Testing Instructions

  • Go to WP admin dashboard.
  • Edit/create any post/page.
  • Create a Page List Block
  • Try to transform it to a list block.

Screenshots or screencast

Screenshare.-.2025-02-10.5_03_26.PM.mp4

Copy link

github-actions bot commented Feb 10, 2025

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: benazeer-ben <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: carolinan <[email protected]>

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

@benazeer-ben
Copy link
Contributor Author

Hi @carolinan , @t-hamano

As discussed in this PR, I have split it into separate PRs—one for navigation and another for the list.

This is the PR for transform to list block.

Please take a look and share your feedback or suggestions.

Thanks in advance!

@shail-mehta shail-mehta added [Type] Enhancement A suggestion for improvement. [Block] Page List Affects the Page List Block labels Feb 10, 2025
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update!

packages/block-library/src/page-list/edit.js Outdated Show resolved Hide resolved
packages/block-library/src/page-list/edit.js Outdated Show resolved Hide resolved
packages/block-library/src/page-list/index.js Show resolved Hide resolved
packages/block-library/src/page-list/edit.js Outdated Show resolved Hide resolved
@benazeer-ben
Copy link
Contributor Author

Thanks a lot for the detailed review @t-hamano

Applied all the above mentioned points in the recent commit.

@t-hamano
Copy link
Contributor

Thanks for the update!

After further testing, I found that this transformation is more complicated than we thought.

For example, the page list is structured as follows. Note that the order has changed for some pages.

  • Page A (Order: 1)
    • Page A -A (Order: 1)
  • Page B (Order: 1)

In the Page List block, it is rendered as follows:

image

However, when this is transformed into a List block, the order changes as follows:

image

The reason is that the block transformation is missing logic for processing the page tree. The Page List block has logic for that: pagesByParentId, pagesTree, and blockList.

Therefore, we need to implement the same logic to the block transformation. Here's the approach I'm thinking of:

  • Create a utils.js file in the page-list directory.
  • Place these three functions in it and export them.
  • Import the three exported functions from both the Edit component and the block transformation.

If you have any questions, please ask.

@benazeer-ben
Copy link
Contributor Author

Thanks for pointing this out, @t-hamano!

I also noticed the order change after the transformation. As you mentioned, we need to account for the tree scenario as well.
I'll try the suggested logic andlet you know the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Page List Affects the Page List Block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transform page list to navigation block and list block
3 participants