WordPress-iOS icon indicating copy to clipboard operation
WordPress-iOS copied to clipboard

P2 Comments: GitHub embed blocks aren't shown

Open twstokes opened this issue 3 years ago • 7 comments

Expected behavior

A GitHub embed block is shown inline with the comments.

Actual behavior

A blank space is shown where the GitHub embed block should be.

Steps to reproduce the behavior

  1. Open Reader
  2. Locate a P2 post that contains a comment with embedded GitHub content (e.g. Issue, PR)
  3. Observe that the space is empty
Desktop Mobile
Screen Shot 2022-03-28 at 11 33 36

Other notes

@AliSoftware found that sometimes the sticky header will disappear. See p1648456550376559-slack-C011BKNU1V5.

Tested on iPhone 12 Pro, iOS 15.4, WPiOS 19.5.0.2

twstokes avatar Mar 28 '22 15:03 twstokes

cc @dvdchr @AliSoftware

twstokes avatar Mar 28 '22 15:03 twstokes

Update on the GitHub embed issue: p1648576909881539-slack-C011BKNU1V5?thread_ts=1648456550.376559

dvdchr avatar Apr 04 '22 08:04 dvdchr

Thanks for reporting! 👍

dangermattic avatar Jul 03 '24 17:07 dangermattic

Tested in trunk with WebKit-based rendered and this issue still reproduces, but the embeds no longer create a large gap. They do no load though.

kean avatar Feb 22 '25 19:02 kean

RCA.

The embeds get stripped out from the content.

(lldb) po comment.content
"<p>Testing GitHub embeds and lists.</p><p></p><p><p></p><p></p><p></p><p></p><p></p><p><p><p></p><p></p><p></p></p></p></p><ul><li>Level one<ul><li>Level two</li></ul></li></ul>"

(lldb) po comment.rawContent
<!-- wp:paragraph -->\n<p>Testing GitHub embeds and lists.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:p2/embed-github -->\n<div class=\"wp-block-p2-embed-github\"><div class=\"wp-block-p2-embed-github__rehydrate-placeholder\"></div><div class=\"wp-block-p2-embed-github__saved\"><div class=\"wp-block-p2-embed-github__main\" title=\"https://github.com/wordpress-mobile/WordPress-iOS/issues/18225\"><div class=\"wp-block-p2-embed-github__data-owner\" title=\"wordpress-mobile\"></div><div class=\"wp-block-p2-embed-github__data-repo\" title=\"WordPress-iOS\"></div><div class=\"wp-block-p2-embed-github__data-item-id\" title=\"18225\"></div><div class=\"wp-block-p2-embed-github__data-item-type\" title=\"issues\"></div><div class=\"wp-block-p2-embed-github__left-container\"><div class=\"wp-block-p2-embed-github__logo\"></div></div><div class=\"wp-block-p2-embed-github__right-container\"><div class=\"wp-block-p2-embed-github__issue\"><div class=\"wp-block-p2-embed-github__issue-content\"><div class=\"wp-block-p2-embed-github__issue-title\"><div class=\"p2-blocks-skeleton-long-text\"></div></div><div class=\"wp-block-p2-embed-github__issue-description\"><div class=\"p2-blocks-skeleton-short-text\"></div><div class=\"p2-blocks-skeleton-medium-text\"></div></div></div></div></div></div></div></div>\n<!-- /wp:p2/embed-github -->\n\n<!-- wp:list -->\n<ul><!-- wp:list-item -->\n<li>Level one<!-- wp:list -->\n<ul><!-- wp:list-item -->\n<li>Level two</li>\n<!-- /wp:list-item --></ul>\n<!-- /wp:list --></li>\n<!-- /wp:list-item --></ul>\n<!-- /wp:list -->

The wp-block-p2-embed-github block itself only contains a bunch of <div>s and clearly won't work without JS (React?).

kean avatar Feb 24 '25 15:02 kean

Note from @jkmassel:

we probably need some server help for this – the server should turn the Gutenberg comment into valid HTML and emit that in the content (with the relevant JS)

My recommendation instead of trying to pass the HTML and JS through would be to just return the GH URL via the API. Sending HTML and JS seems tricky and may pose security concerns? @jkmassel do you think that would be acceptable?

Also, just noting this comment form the Slack discussion:

Given my understanding of this recent SIRT post p3btAN-1Iv-p2 … my understanding is that GitHub Embed are likely restricted to P2s

davemart-in avatar Mar 10 '25 12:03 davemart-in

Does anyone know why the GitHub embed block requires JavaScript? My perception is that it is not interactive, aside from lazy loading the issue information. Presumably the entire block could be server-rendered, where the server solely returns styled HTML.

dcalhoun avatar Mar 10 '25 13:03 dcalhoun