Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 798 forks source link

Jetpack Comments: nested comments with async load of comments #15287

Open geoffguillain opened 4 years ago

geoffguillain commented 4 years ago

Is your feature request related to a problem? Please describe.

When comments are loaded asynchronously in a template, the Jetpack Comments module won't work for nested comments.

Jetpack Comments is enqueuing the watch_comment_parent() function/script in comment_form_before() function using the wp_footer action hook. Loading the comments asynchronously, the wp_footer hook is already executed and no event listeners would be added. This is preventing the nested comments to work as the comment_parent hidden field won’t be updated.

Describe the solution you'd like

I would like the JS in the watch_comment_parent() function to be accessible outside of the closure with any kind of hook/API that we could trigger for this async use case

Describe alternatives you've considered

A workaround would be for the async comments to include this js snippet as well when the comments are loaded which is working but it sums up in mostly in copy-pasting the JS from watch_comment_parent() which is not elegant neither will be future proof if the Jetpack Comments feature evolves.

Additional context

n/a

stale[bot] commented 4 years ago

This issue has been marked as stale. This happened because:

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.