Automattic / Automattic/jetpack

Slideshow Block: additional event listeners for init

Open
#19,182 1 comment 0 reactions 0 assignees View on GitHub
[Block] Slideshow [Focus] Blocks [Plugin] Jetpack [Pri] Low Enhancement Good For Community
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

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

The [initialization function responsible for making slideshow blocks work](https://github.com/Automattic/jetpack/blob/master/projects/plugins/jetpack/extensions/blocks/slideshow/view.js#L20) is run on `DOMContentLoaded`. For themes whose posts are dynamically rendered, this may be too early.

Some events also trigger a re-render of the post, e.g. for o2-powered themes, pinning or unpinning a post.

Slideshow blocks in these scenarios don't work as expected.

#### Describe the solution you'd like

In addition to listening for `DOMContentLoaded` (via `domReady`) can we add another event listener for triggering the init code when a post is rendered? Maybe something like a `post-rendered` event, which themes/plugins can trigger when posts are dynamically rendered.

#### Describe alternatives you've considered

2262-gh-Automattic/p2 is a workaround that re-evals the init script to make slideshow blocks work for `pub/p2020`.

#### Additional context

Contributor guide

Open the contributing guide

Research direction

Start in projects/plugins/jetpack/extensions/blocks/slideshow/view.js at the initialization function linked in the issue, and review how domReady currently triggers it. Compare that flow with the 2262-gh-Automattic/p2 workaround and determine the post-rendered event contract. Done means slideshow blocks initialize correctly after dynamically rendered posts as well as on DOMContentLoaded.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, wordpress
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.