Skip to content

Playlist: Skip hidden tracks when building the track list - #87070

Open
yashjawale wants to merge 9 commits into
WordPress:trunkfrom
yashjawale:fix/playlist-hidden-blocks
Open

yashjawale wants to merge 9 commits into
WordPress:trunkfrom
yashjawale:fix/playlist-hidden-blocks

Conversation

@yashjawale

Copy link
Copy Markdown
Contributor

What?

Closes #87069

This PR prevents Hidden tracks from being added added to the Playlist block's track list on the front end.

Why?

Hidden tracks still got a track ID even though their button wasn't on the page. The visible buttons are matched to IDs in order, so each one played the track before it, and the player loaded the hidden track first.

How?

Tracks whose metadata.blockVisibility is false are skipped when building the track list, same as the check the visibility feature uses to remove the block.

Adds test cases for the same.

Testing Instructions

Get sample wave files to help test here: one.wav two.wav three.wav

  1. Add a Playlist block to a post with three audio tracks: one, two and three.
  2. Select track one, open the block toolbar's Options menu and choose "Hide".
  3. Save and view the post on the front end.
  4. Check that the player loads track two, and that clicking two and three plays tracks two and three instead of playing one.

Screenshots or screencast

Before

Screen.Recording.2026-11-19.at.1.59.19.PM.mov

After

Screen.Recording.2026-11-19.at.2.00.08.PM.mov

Use of AI Tools

Assisted by Claude Code.
All changes reviewed & tested manually.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: yashjawale <yashjawale@git.wordpress.org>
Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Nov 19, 2026
@hbhalodia hbhalodia added [Type] Bug An existing feature does not function as intended [Block] Playlist labels Nov 19, 2026
@hbhalodia
hbhalodia requested a balanced review from Copilot November 19, 2026 09:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the playlist alignment fix that excludes hidden tracks.

No open issues 🎉

What changed in this PR

Fixes Playlist playback alignment when tracks are hidden, addressing #87069 by excluding hidden tracks from the front-end track list.

Changes:

  • Skips tracks whose metadata.blockVisibility is explicitly false.
  • Adds a regression test verifying that the remaining visible track receives the correct ID and audio URL.
File Description
phpunit/​blocks/​render-block-playlist-test.php Tests track IDs and audio mapping when the first track is hidden.
packages/​block-library/​src/​playlist/​index.php Excludes hidden tracks before assigning playlist track IDs.

Review effort: Balanced

@hbhalodia hbhalodia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yashjawale, I have tested this and found some issues. Can you please look on those?

Comment on lines +37 to +40
if ( false === ( $inner_block->parsed_block['attrs']['metadata']['blockVisibility'] ?? null ) ) {
continue;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yashjawale, This won't work as expected when it's being hidden only on a single viewport or combination. The attributes we would be getting would be something like this. So all of this needs to be consider.

[metadata] => Array
        (
            [blockVisibility] => Array
                (
                    [viewport] => Array
                        (
                            [desktop] => 
                            [mobile] => 
                        )
                )
        )

Also, $inner_block->parsed_block['attrs']['metadata']['blockVisibility'], instead we are having $track_attributes, let's use that for the check instead of getting it again from the innerblock.

Screen.Recording.2026-11-19.at.2.58.46.PM.mov

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also update the test case to include all this scenario.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
Updated to use $track_attributes and now handling partially hidden blocks in viewjs script.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also included additional test cases for different scenarios.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Playback stops after the first track when the tracklist is disabled, and initialization still exposes a hidden track when no tracks are visible at the current breakpoint.

2 open issues

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Playlist [Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Playlist: Hiding a track makes the other tracks play the wrong audio

3 participants