Skip to content
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

InputControl-based components: Add opt-in prop for next 40px default size #53819

Merged
merged 13 commits into from
Sep 29, 2023
Prev Previous commit
Next Next commit
TreeSelect: Add opt-in prop for next 40px default size
  • Loading branch information
mirka authored and chad1008 committed Sep 29, 2023
commit 2c5dc8818ff277bbcf826f677948864bf68adbdf
25 changes: 16 additions & 9 deletions packages/components/src/tree-select/index.tsx
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import { decodeEntities } from '@wordpress/html-entities';
*/
import { SelectControl } from '../select-control';
import type { TreeSelectProps, Tree, Truthy } from './types';
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';

function getSelectOptions(
tree: Tree[],
@@ -72,14 +73,20 @@ function getSelectOptions(
* ```
*/

export function TreeSelect( {
label,
noOptionLabel,
onChange,
selectedId,
tree = [],
...props
}: TreeSelectProps ) {
export function TreeSelect( props: TreeSelectProps ) {
const {
label,
noOptionLabel,
onChange,
selectedId,
tree = [],
...restProps
} = useDeprecated36pxDefaultSizeProp(
props,
'wp.components.TreeSelect',
'6.4'
);

const options = useMemo( () => {
return [
noOptionLabel && { value: '', label: noOptionLabel },
@@ -91,7 +98,7 @@ export function TreeSelect( {
<SelectControl
{ ...{ label, options, onChange } }
value={ selectedId }
{ ...props }
{ ...restProps }
/>
);
}