Commit bfbe6e1
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.
Treat a link with a binding or a resolved record as a known entity: skip the
rich URL data fetch for it (including while a bound entity is still resolving)
and ignore rich data in the title fallback, so a title scraped for a prior URL
can't leak after switching the link to an untitled entity. An empty entity
title is valid data, not a cue to scrape the page.
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 bfbe6e1
2 files changed
Lines changed: 88 additions & 5 deletions
File tree
Lines changed: 73 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 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
503 | 576 | | |
504 | 577 | | |
505 | 578 | | |
| |||
Lines changed: 15 additions & 5 deletions
| 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 | | - | |
232 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
233 | 241 | | |
234 | 242 | | |
235 | 243 | | |
| |||
275 | 283 | | |
276 | 284 | | |
277 | 285 | | |
278 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
279 | 289 | | |
280 | | - | |
| 290 | + | |
281 | 291 | | |
282 | 292 | | |
283 | 293 | | |
| |||
0 commit comments