Page List: Show empty placeholder if no items#35441
Conversation
|
@jasmussen I use just the default |
|
Size Change: +2.2 kB (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
tellthemachines
left a comment
There was a problem hiding this comment.
Looks good! Just a minor comment below, but not a blocker.
| // Return early and empty to trigger EmptyResponsePlaceholder. | ||
| if ( empty( $top_level_pages ) ) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
We could return even earlier if we instead checked $all_pages above.
|
After: The first is the page list inside navigation, the second is just a standalone page list. I also confirmed that the placeholder is only shown in the editor. However, in light of what we're doing to other FSE blocks (see #35243 and #35242), I think we should avoid the use of the Removing the placeholder could make it look like this: This is the markup I inspected myself to: |
This makes it more clear and bails out even earlier.
|
Thanks @tellthemachines good catch, I moved the check up even earlier, which also makes it more clear. Thanks @jasmussen, I simplified the placeholder to just that span tag. 👍 |
|
Nice! Ship it. |
|
@mkaz Two side effects of this one:
GIF showing the message, and the spinner recurring: This makes the block feel a bit brittle. Can we follow up with a few tweaks?
|





Description
If no pages exist the Page List block will be empty, making it impossible to select in the rendered view in editor. This PR adds an empty placeholder to show where the block would be and allows for selecting in rendered view.
The Page List block can be empty if a user deletes all pages, or while working on #31471 there may be no children when showing a child list.
How has this been tested?
Screenshots
Types of changes