Skip to content
1 change: 1 addition & 0 deletions packages/block-library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

- Icon: Apply only padding to the inner SVG in the editor, so margin is no longer applied twice compared to the front end ([#81292](https://github.com/WordPress/gutenberg/pull/81292)).
- Playlist: Attach the inner block drop zone to the track list, so Playlist Track blocks show insertion markers while being reordered.
- Playlist Track: Hide the Title and Replace audio controls when multiple tracks are selected.
- Playlist Track: Mark track media fields as content so toolbar inserters add an empty track instead of duplicating the selected track.
- Tabs: Number the generated tab IDs from 1 and keep them sequential, so IDs generated by other blocks on the page no longer shift the numbering ([#81781](https://github.com/WordPress/gutenberg/pull/81781)).
- Playlist: Stop sharing the parent "Add track" toolbar control with selected Playlist Track child blocks ([#81432](https://github.com/WordPress/gutenberg/pull/81432)).
Expand Down
44 changes: 25 additions & 19 deletions packages/block-library/src/playlist-track/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,33 @@ const PlaylistTrackEdit = ( {

return (
<>
<BlockControls group="other">
<MediaReplaceFlow
name={ __( 'Replace' ) }
onSelect={ onSelectTrack }
accept="audio/*"
mediaId={ id }
mediaURL={ src }
allowedTypes={ ALLOWED_MEDIA_TYPES }
onError={ onUploadError }
variant="toolbar"
/>
</BlockControls>
{ /* Only show if this is a single selection (not multiselect) */ }
{ isSelected && (

@jeryj jeryj Aug 21, 2026 •

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.

If this naming feels too wrong we can also use isMultiselected but we'd need to open the PrivateBlockContext can of worms for something that works and is part of the accepted contract for what isSelected means.

Pointing it out, but I think we should rely on isSelected here and not go the Private API route.

<BlockControls group="other">
<MediaReplaceFlow
name={ __( 'Replace' ) }
onSelect={ onSelectTrack }
accept="audio/*"
mediaId={ id }
mediaURL={ src }
allowedTypes={ ALLOWED_MEDIA_TYPES }
onError={ onUploadError }
variant="toolbar"
/>
</BlockControls>
) }
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
{ /* Only show if this is a single selection (not multiselect) */ }
{ isSelected && (
<TextControl
label={ __( 'Title' ) }
value={ title ? stripHTML( title ) : '' }
onChange={ ( titleValue ) => {
setAttributes( { title: titleValue } );
} }
/>
) }
<TextControl
label={ __( 'Artist' ) }
value={ artist ? stripHTML( artist ) : '' }
Expand All @@ -172,13 +185,6 @@ const PlaylistTrackEdit = ( {
setAttributes( { album: albumValue } );
} }
/>
<TextControl
label={ __( 'Title' ) }
value={ title ? stripHTML( title ) : '' }
onChange={ ( titleValue ) => {
setAttributes( { title: titleValue } );
} }
/>
<MediaUploadCheck>
<BaseControl>
<BaseControl.VisualLabel>
Expand Down
41 changes: 39 additions & 2 deletions packages/block-library/src/playlist-track/test/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,43 @@ describe( 'PlaylistTrackEdit', () => {
useUploadMediaFromBlobURL.mockClear();
} );

it( 'shows the title control for a single selected playlist track', () => {
renderEdit( { isSelected: true } );

expect(
screen.getByRole( 'textbox', { name: 'Title' } )
).toBeInTheDocument();
} );

it( 'shows the replace track control for a single selected playlist track', () => {
renderEdit( { isSelected: true } );

expect( mockMediaReplaceFlowProps ).toBeDefined();
} );

it( 'does not show the replace track control when multiple playlist tracks are selected', () => {
renderEdit( { isSelected: false } );

expect( mockMediaReplaceFlowProps ).toBeUndefined();
} );

it( 'does not show the title control when multiple playlist tracks are selected', () => {
// The track inspector only renders for the selected block, or for the
// first block of a same-type multi-selection, where `isSelected` is
// false.
renderEdit( { isSelected: false } );

expect(
screen.queryByRole( 'textbox', { name: 'Title' } )
).not.toBeInTheDocument();
expect(
screen.getByRole( 'textbox', { name: 'Artist' } )
).toBeInTheDocument();
expect(
screen.getByRole( 'textbox', { name: 'Album' } )
).toBeInTheDocument();
} );

it( 'allows the track image alternative text to be edited', () => {
const { setAttributes } = renderEdit();

Expand Down Expand Up @@ -188,7 +225,7 @@ describe( 'PlaylistTrackEdit', () => {
} );

it( 'preserves the current track source when a replacement upload fails', () => {
const { setAttributes } = renderEdit();
const { setAttributes } = renderEdit( { isSelected: true } );

mockMediaReplaceFlowProps.onSelect();

Expand All @@ -199,7 +236,7 @@ describe( 'PlaylistTrackEdit', () => {
} );

it( 'accepts raw uploaded attachment data when replacing a track', () => {
const { setAttributes } = renderEdit();
const { setAttributes } = renderEdit( { isSelected: true } );

mockMediaReplaceFlowProps.onSelect( {
id: 2,
Expand Down
Loading