Repository navigation
Playlist: Skip hidden tracks when building the track list - #87070
yashjawale wants to merge 9 commits into
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the |
There was a problem hiding this comment.
🟢 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.blockVisibilityis explicitlyfalse. - 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
left a comment
There was a problem hiding this comment.
Hi @yashjawale, I have tested this and found some issues. Can you please look on those?
| if ( false === ( $inner_block->parsed_block['attrs']['metadata']['blockVisibility'] ?? null ) ) { | ||
| continue; | ||
| } | ||
|
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Let's also update the test case to include all this scenario.
There was a problem hiding this comment.
Thanks!
Updated to use $track_attributes and now handling partially hidden blocks in viewjs script.
There was a problem hiding this comment.
Also included additional test cases for different scenarios.

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.blockVisibilityisfalseare 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
one,twoandthree.one, open the block toolbar's Options menu and choose "Hide".two, and that clickingtwoandthreeplays trackstwoandthreeinstead of playingone.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.