alleyinteractive / alleyinteractive/wp-curate

core/post-featured-image link-to-post options don't appear inside wp-curate/query

Abierto
#474 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
PHP
Estrellas
11
Forks
3
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### Description of the bug

## Summary

When `core/post-featured-image` is placed inside `wp-curate/query` (nested `core/post-template` > `wp-curate/post` > `core/post-featured-image`), the "Link to post" settings panel (link toggle, open-in-new-tab, link relation) does not reliably appear the way it does inside a native `core/query` block.

## Root cause

`core/post-featured-image`'s edit component determines whether it's inside a query loop via block context, specifically the `queryId` value:

```js
// @wordpress/block-library/src/post-featured-image/edit.js
context: { postId, postType: postTypeSlug, queryId },
...
const isDescendentOfQueryLoop = Number.isFinite( queryId );
```
The "Settings" panel containing the link controls is only rendered when:
`( featuredImage || isDescendentOfQueryLoop || ! postId )`

`queryId` context is provided by `core/query`, which has its own `queryId` attribute mapped in its block.json:
```json
"providesContext": {
"queryId": "queryId",
"query": "query",
"displayLayout": "displayLayout",
"enhancedPagination": "enhancedPagination"
}
```

`wp-curate/query` has no `queryId` attribute and its providesContext does not include queryId.

`postId/postType` context still reach `core/post-featured-image` normally (context flows through the whole block tree, not just immediate parents), but `queryId` is always undefined under `wp-curate/query`. As a result `isDescendentOfQueryLoop` evaluates to false, so for any curated post that doesn't already have a stored featured image, the whole "Settings" panel — including the link-to-post controls — is suppressed. It also means the image-replace toolbar behaves as if the block were editing a single, non-loop post rather than a loop item, which is the opposite of the intended "don't let editors swap images for arbitrary posts in a loop" protection core ships with.

### Steps To Reproduce

1. Add a `wp-curate/query` block to a post/page.
2. Inside its core/post-template, add a `wp-curate/post` block, and inside that a core/post-featured-image block.
3. Select a curated post that has no featured image stored yet.
4. Open the block settings sidebar — the "Link to post" panel (isLink / open in new tab / link relation) is missing, unlike the same structure under a native core/query.

### Additional Information

## Suggested fix

Add a queryId attribute to `wp-curate/query` block.json and map it in providesContext:
```json
"attributes": {
"queryId": { "type": "number" },
...
},
"providesContext": {
"queryId": "queryId",
"query": "query",
...
}
```
That alone restores `isDescendentOfQueryLoop` detection for `core/post-featured-image` (and any other core block that keys off queryId, e.g. core/post-template's own behaviors).

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.