Commit 9df0e19
Navigation Link: Fix "[object Object]" in link preview for untitled entities
For a page with an empty title the entity record's title is
`{ raw: '', rendered: '' }`, so `entityRecord?.title?.rendered` is an empty
string and the link preview's title computation fell through to
`entityRecord?.title` -- the title object itself -- which renders as
"[object Object]".
Only fall back to `entityRecord.title` when it is a plain string (some entity
types expose it that way) so the object is never surfaced.
Before WordPress#77170 this rendered an object as a React child and crashed the block
("This block has encountered an error and cannot be previewed"). WordPress#77170
wrapped the preview title in stripHTML, which coerced the object to the
harmless "[object Object]" string; this addresses the underlying cause.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 23f80e8 commit 9df0e19
2 files changed
Lines changed: 19 additions & 1 deletion
File tree
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
503 | 519 | | |
504 | 520 | | |
505 | 521 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
| |||
0 commit comments