Skip to content

Commit 2729ce2

Browse files
authored
VideoPress: Replace custom Checkbox with CheckboxControl, fix invisible filter/privacy checkboxes (#48175)
* VideoPress: Swap site-settings privacy toggle to CheckboxControl The Video Privacy toggle at the bottom of the VideoPress dashboard was using the local CheckboxCheckmark wrapper around a custom-styled checkbox that relied on a ::before pseudo-element for its visible box but never defined background/border, leaving the control blank on top of any cascade that didn't paint a default. Replace it with WP's @wordpress/components CheckboxControl for native rendering and accessibility, and move the component-local layout rule (margin-top for spacing under the Settings heading) into its own style.module.scss alongside the consumer. Also routes the existing disabledReason copy through CheckboxControl's `help` prop. * VideoPress: Remove unused custom Checkbox component and dead selection UI Now that the site-settings privacy toggle uses @wordpress/components CheckboxControl directly, the local Checkbox component is only used by: - video-filter's CheckboxCheckmark (filter panel on the library page) - video-list / video-row "select all" + per-row selection checkboxes, both permanently gated behind a hardcoded `showCheckbox = false` with a `// TODO: implement bulk actions` note — never rendered in the current UI Migrate CheckboxCheckmark to CheckboxControl and delete the list/row selection plumbing entirely, then remove the components/checkbox/ directory (component, styles, stories, tests, types). video-filter: - CheckboxCheckmark now renders CheckboxControl with a .filter-checkbox class that adds `padding-top: var(--spacing-base)` for vertical rhythm between filter options. - Drop the `for` and `disabledReason` props plus the internal DisabledReasonTooltip — neither was actually used by any call site. - Remove now-dead `.filters-section .checkbox-container:last-child` and `.title-adornment` rules. video-list: - Remove `selected` / `setSelected` state, `allSelected`, `handleAll`, and the `showCheckbox = false` constant from both VideoList and LocalVideoList. - Drop the select-all header checkbox and stop passing `checked` / `onSelect` / `showCheckbox` through to the row components. video-row: - Drop the CheckboxControl render block + wrapper div. - Drop `checked`, `onSelect`, `showCheckbox` props from the signature and the VideoRowProps type. - Drop the row-level keyboard/click handling that only existed to toggle the (never-rendered) checkbox: `role=button`, `tabIndex`, `aria-label`, `onKeyDown`, `onKeyUp`, `keyPressed` state, `handleKeyDown`/`handleKeyUp`/`handleClick`/`isSpaceOrEnter`. - Simplify `handleInfoWrapperClick` to only toggle mobile expansion. - Remove the orphan `.checkbox-wrapper-small` SCSS rule (`.pressed` stays — still used by video-row/error.tsx). Net: ~377 lines of dead code gone, no visible UI change. * changelog: Add entries for VideoPress checkbox cleanup
1 parent 2ddb7d5 commit 2729ce2

15 files changed

Lines changed: 26 additions & 392 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: removed
3+
4+
Remove unused custom Checkbox component and the hidden per-row selection UI that relied on it.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: changed
3+
4+
Swap the site-settings Video Privacy toggle to WordPress CheckboxControl for native rendering and accessibility.

projects/packages/videopress/src/client/admin/components/checkbox/index.tsx

Lines changed: 0 additions & 43 deletions
This file was deleted.

projects/packages/videopress/src/client/admin/components/checkbox/stories/index.stories.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

projects/packages/videopress/src/client/admin/components/checkbox/style.module.scss

Lines changed: 0 additions & 57 deletions
This file was deleted.

projects/packages/videopress/src/client/admin/components/checkbox/test/index.tsx

Lines changed: 0 additions & 93 deletions
This file was deleted.

projects/packages/videopress/src/client/admin/components/checkbox/types.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

projects/packages/videopress/src/client/admin/components/site-settings-section/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
* External dependencies
33
*/
44
import { Col, Container, Text } from '@automattic/jetpack-components';
5+
import { CheckboxControl } from '@wordpress/components';
56
import { __ } from '@wordpress/i18n';
67
/**
78
* Internal dependencies
89
*/
910
import { usePermission } from '../../hooks/use-permission';
1011
import { useVideoPressSettings } from '../../hooks/use-videopress-settings';
11-
import { CheckboxCheckmark } from '../video-filter';
1212
import { SITE_TYPE_ATOMIC } from './constants';
13+
import styles from './style.module.scss';
1314
import { SiteSettingsSectionProps } from './types';
1415
/**
1516
* Types
@@ -46,16 +47,16 @@ const SiteSettingsSection: FC< SiteSettingsSectionProps > = ( {
4647
</Text>
4748
</Col>
4849
<Col sm={ 12 } md={ 12 } lg={ 12 }>
49-
<CheckboxCheckmark
50-
for={ 'settings-site-privacy' }
50+
<CheckboxControl
5151
label={ __(
5252
'Video Privacy: Restrict views to members of this site',
5353
'jetpack-videopress-pkg'
5454
) }
55+
className={ styles[ 'privacy-toggle' ] }
5556
onChange={ onPrivacyChange }
5657
checked={ videoPressVideosPrivateForSite }
5758
disabled={ disablePrivacyToggle }
58-
disabledReason={ disabledReason }
59+
help={ disabledReason || undefined }
5960
/>
6061
</Col>
6162
</Container>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.privacy-toggle {
2+
margin-top: var(--spacing-base);
3+
}

projects/packages/videopress/src/client/admin/components/video-filter/index.tsx

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
* External dependencies
33
*/
44
import { Button, Col, Container, Text, useBreakpointMatch } from '@automattic/jetpack-components';
5-
import { Tooltip } from '@wordpress/components';
5+
import { CheckboxControl } from '@wordpress/components';
66
import { __ } from '@wordpress/i18n';
7-
import { Icon, info } from '@wordpress/icons';
87
import clsx from 'clsx';
98
/**
109
* Types
@@ -28,7 +27,6 @@ import {
2827
import { useSearchParams } from '../../hooks/use-search-params';
2928
import useUsers from '../../hooks/use-users';
3029
import useVideos from '../../hooks/use-videos';
31-
import Checkbox from '../checkbox';
3230
import styles from './style.module.scss';
3331
import { FilterObject } from './types';
3432
import type { JSX } from 'react';
@@ -54,36 +52,20 @@ export const FilterButton = ( props: {
5452
);
5553
};
5654

57-
const DisabledReasonTooltip = ( props: { message: string } ): JSX.Element => {
58-
return (
59-
<Tooltip position="middle center" text={ props.message }>
60-
<span className={ styles[ 'title-adornment' ] }>
61-
<Icon icon={ info } />
62-
</span>
63-
</Tooltip>
64-
);
65-
};
66-
6755
export const CheckboxCheckmark = ( props: {
6856
label?: string;
69-
for: string;
7057
checked?: boolean;
7158
disabled?: boolean;
72-
disabledReason?: string;
7359
onChange?: ( checked: boolean ) => void;
7460
} ): JSX.Element => {
7561
return (
76-
<Checkbox
77-
id={ props.for }
78-
htmlFor={ props.for }
79-
className={ styles.checkbox }
80-
onChange={ props.onChange }
62+
<CheckboxControl
63+
className={ styles[ 'filter-checkbox' ] }
64+
label={ props.label }
8165
checked={ props.checked }
8266
disabled={ props.disabled }
83-
>
84-
<Text variant="body-small">{ props.label }</Text>
85-
{ props.disabledReason && <DisabledReasonTooltip message={ props.disabledReason } /> }
86-
</Checkbox>
67+
onChange={ props.onChange }
68+
/>
8769
);
8870
};
8971

@@ -117,7 +99,6 @@ export const FilterSection = ( props: {
11799
<CheckboxCheckmark
118100
key={ uploader.id }
119101
label={ uploader.name }
120-
for={ `uploader-${ uploader.id }` }
121102
onChange={ checked =>
122103
props.onChange?.( VIDEO_FILTER_UPLOADER, uploader.id, checked )
123104
}
@@ -131,7 +112,6 @@ export const FilterSection = ( props: {
131112
{ __( 'Privacy', 'jetpack-videopress-pkg' ) }
132113
</Text>
133114
<CheckboxCheckmark
134-
for="filter-public"
135115
label={ __( 'Public', 'jetpack-videopress-pkg' ) }
136116
onChange={ checked =>
137117
props.onChange?.(
@@ -146,7 +126,6 @@ export const FilterSection = ( props: {
146126
) }
147127
/>
148128
<CheckboxCheckmark
149-
for="filter-private"
150129
label={ __( 'Private', 'jetpack-videopress-pkg' ) }
151130
onChange={ checked =>
152131
props.onChange?.(
@@ -167,21 +146,18 @@ export const FilterSection = ( props: {
167146
{ __( 'Rating', 'jetpack-videopress-pkg' ) }
168147
</Text>
169148
<CheckboxCheckmark
170-
for="filter-g"
171149
label={ __( 'G', 'jetpack-videopress-pkg' ) }
172150
onChange={ checked => props.onChange?.( VIDEO_FILTER_RATING, VIDEO_RATING_G, checked ) }
173151
checked={ filterIsChecked( VIDEO_FILTER_RATING, VIDEO_RATING_G ) }
174152
/>
175153
<CheckboxCheckmark
176-
for="filter-pg-13"
177154
label={ __( 'PG-13', 'jetpack-videopress-pkg' ) }
178155
onChange={ checked =>
179156
props.onChange?.( VIDEO_FILTER_RATING, VIDEO_RATING_PG_13, checked )
180157
}
181158
checked={ filterIsChecked( VIDEO_FILTER_RATING, VIDEO_RATING_PG_13 ) }
182159
/>
183160
<CheckboxCheckmark
184-
for="filter-r"
185161
label={ __( 'R', 'jetpack-videopress-pkg' ) }
186162
onChange={ checked =>
187163
props.onChange?.( VIDEO_FILTER_RATING, VIDEO_RATING_R_17, checked )

0 commit comments

Comments
 (0)