-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Video: Enable support for adding multiple tracks #70689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Video: Enable support for adding multiple tracks #70689
Conversation
d063e3a
to
b59bd18
Compare
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.
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. |
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 If 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. |
0ce235d
to
fb6e26e
Compare
@@ -61,7 +60,7 @@ function TrackList( { tracks, onEditPress } ) { | |||
const content = tracks.map( ( track, index ) => { | |||
return ( | |||
<HStack | |||
key={ track.src } | |||
key={ track.id } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -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 } />; |
There was a problem hiding this comment.
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.
const uploadedTracks = selectedTracks?.filter( | ||
( track ) => !! track?.id | ||
); |
There was a problem hiding this comment.
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?
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. |
No worries. I miss things all the time 😄 |
Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
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 bothFormFileUpload
andMediaUpload
components and handled the selection logic appropriately.Testing Instructions
Testing Instructions for Keyboard
Same.
Screencast
pr-demo.mov