Skip to content

Commit 6570834

Browse files
Audio and Video: Hide caption controls in contentOnly mode (#71368)
* Audio and Video: Hide caption and text tracks controls in contentOnly mode * Reinstate Text tracks control Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
1 parent d919b29 commit 6570834

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/block-library/src/audio/edit.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
MediaPlaceholder,
2323
MediaReplaceFlow,
2424
useBlockProps,
25+
useBlockEditingMode,
2526
} from '@wordpress/block-editor';
2627
import { __, _x } from '@wordpress/i18n';
2728
import { useDispatch } from '@wordpress/data';
@@ -51,6 +52,8 @@ function AudioEdit( {
5152
} ) {
5253
const { id, autoplay, loop, preload, src } = attributes;
5354
const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
55+
const blockEditingMode = useBlockEditingMode();
56+
const hasNonContentControls = blockEditingMode === 'default';
5457

5558
useUploadMediaFromBlobURL( {
5659
url: temporaryURL,
@@ -264,7 +267,9 @@ function AudioEdit( {
264267
isSelected={ isSingleSelected }
265268
insertBlocksAfter={ insertBlocksAfter }
266269
label={ __( 'Audio caption text' ) }
267-
showToolbarButton={ isSingleSelected }
270+
showToolbarButton={
271+
isSingleSelected && hasNonContentControls
272+
}
268273
/>
269274
</figure>
270275
</>

packages/block-library/src/video/edit.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
MediaPlaceholder,
2121
MediaReplaceFlow,
2222
useBlockProps,
23+
useBlockEditingMode,
2324
} from '@wordpress/block-editor';
2425
import { useRef, useEffect, useState } from '@wordpress/element';
2526
import { __ } from '@wordpress/i18n';
@@ -55,6 +56,8 @@ function VideoEdit( {
5556
const { id, controls, poster, src, tracks } = attributes;
5657
const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
5758
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
59+
const blockEditingMode = useBlockEditingMode();
60+
const hasNonContentControls = blockEditingMode === 'default';
5861

5962
useUploadMediaFromBlobURL( {
6063
url: temporaryURL,
@@ -251,7 +254,9 @@ function VideoEdit( {
251254
isSelected={ isSingleSelected }
252255
insertBlocksAfter={ insertBlocksAfter }
253256
label={ __( 'Video caption text' ) }
254-
showToolbarButton={ isSingleSelected }
257+
showToolbarButton={
258+
isSingleSelected && hasNonContentControls
259+
}
255260
/>
256261
</figure>
257262
</>

0 commit comments

Comments
 (0)