Skip to content

Conversation

yogeshbhutkar
Copy link
Contributor

@yogeshbhutkar yogeshbhutkar commented Jul 11, 2025

What?

Closes #70688

This PR implements support for adding multiple tracks to the video block.

Why?

This would allow users to attach multiple track files at once, eliminating the need to repeat the process for each file.

How?

Enabled multiple option for both FormFileUpload and MediaUpload components and handled the selection logic appropriately.

Testing Instructions

  1. Create a new post.
  2. Insert a video block.
  3. Confirm being able to attach multiple tracks to the video block.

Testing Instructions for Keyboard

Same.

Screencast

pr-demo.mov

@yogeshbhutkar yogeshbhutkar changed the title Video: Enable support for uploading and selecting multiple tracks Video: Enable support for adding multiple tracks Jul 11, 2025
@yogeshbhutkar yogeshbhutkar force-pushed the feat/tracks-editor-multi-file-support branch from d063e3a to b59bd18 Compare July 11, 2025 09:33
@yogeshbhutkar yogeshbhutkar marked this pull request as ready for review July 11, 2025 10:38
Copy link

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

Copy link

github-actions bot commented Jul 11, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

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: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

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

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. [Block] Video Affects the Video Block labels Jul 11, 2025
@yogeshbhutkar yogeshbhutkar force-pushed the feat/tracks-editor-multi-file-support branch from 0ce235d to fb6e26e Compare July 14, 2025 03:52
@@ -61,7 +60,7 @@ function TrackList( { tracks, onEditPress } ) {
const content = tracks.map( ( track, index ) => {
return (
<HStack
key={ track.src }
key={ track.id }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
key={ track.id }
key={ track.id ?? track.src }

We'll need a fallback here. Otherwise, previously inserted video block tracks will display an error, since the id value isn't available for them.

P.S. You should always test with old block markup when making similar changes, in addition to the newly inserted block.

Screenshot

CleanShot 2025-07-14 at 11 23 57

@@ -1,5 +1,6 @@
export default function Tracks( { tracks = [] } ) {
return tracks.map( ( track ) => {
return <track key={ track.src } { ...track } />;
const { id, ...trackAttrs } = track;
return <track key={ id } { ...trackAttrs } />;
Copy link
Member

Choose a reason for hiding this comment

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

Same here, just to be on the safe side.

Comment on lines 241 to 243
const uploadedTracks = selectedTracks?.filter(
( track ) => !! track?.id
);
Copy link
Member

Choose a reason for hiding this comment

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

The selectedTracks should always be an array. Should also check that uploadedTracks isn't empty and avoid calling handleTrackSelect for those cases?

@yogeshbhutkar
Copy link
Contributor Author

Thanks for the review, @Mamaduka.

Apologies for missing the pointers mentioned above; I've included them in the latest commit. Thanks again for pointing them out.

@Mamaduka
Copy link
Member

Apologies for missing the pointers mentioned above; I've included them in the latest commit. Thanks again for pointing them out.

No worries. I miss things all the time 😄

@Mamaduka Mamaduka merged commit f433291 into WordPress:trunk Jul 14, 2025
56 of 92 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.3 milestone Jul 14, 2025
cbravobernal pushed a commit that referenced this pull request Jul 15, 2025
Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Video Affects the Video Block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Video: Add support for uploading/selecting multiple tracks
2 participants