Skip to content

Commit

Permalink
Missed spots
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Aug 12, 2024
1 parent 2b2fb30 commit 0b5efce
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/components/src/dimension-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ContextSystemProvider } from '../context';
const CONTEXT_VALUE = {
BaseControl: {
// Temporary during deprecation grace period: Overrides the underlying `__associatedWPComponentName`
// via the context system to override the value set by SearchControl.
// via the context system to override the value set by SelectControl.
_overrides: { __associatedWPComponentName: 'DimensionControl' },
},
};
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/textarea-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function UnforwardedTextareaControl(
return (
<BaseControl
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
__associatedWPComponentName="TextareaControl"
label={ label }
hideLabelFromVision={ hideLabelFromVision }
id={ id }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const Template: StoryFn< typeof TextareaControl > = ( {

export const Default: StoryFn< typeof TextareaControl > = Template.bind( {} );
Default.args = {
__nextHasNoMarginBottom: true,
label: 'Text',
help: 'Enter some text',
};
9 changes: 9 additions & 0 deletions packages/components/src/toggle-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import clsx from 'clsx';
*/
import { forwardRef } from '@wordpress/element';
import { useInstanceId } from '@wordpress/compose';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand Down Expand Up @@ -48,6 +49,14 @@ function UnforwardedToggleControl(
! __nextHasNoMarginBottom && css( { marginBottom: space( 3 ) } )
);

if ( ! __nextHasNoMarginBottom ) {
deprecated( 'Bottom margin styles for wp.components.ToggleControl', {
since: '6.7',
version: '7.0',
hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.',
} );
}

let describedBy, helpLabel;
if ( help ) {
if ( typeof help === 'function' ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const Template: StoryFn< typeof ToggleControl > = ( {

export const Default = Template.bind( {} );
Default.args = {
__nextHasNoMarginBottom: true,
label: 'Enable something',
};

Expand Down
8 changes: 7 additions & 1 deletion packages/components/src/toggle-control/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { render, screen } from '@testing-library/react';
/**
* Internal dependencies
*/
import ToggleControl from '..';
import _ToggleControl from '..';

const ToggleControl = (
props: React.ComponentProps< typeof _ToggleControl >
) => {
return <_ToggleControl { ...props } __nextHasNoMarginBottom />;
};

describe( 'ToggleControl', () => {
it( 'should label the toggle', () => {
Expand Down
21 changes: 16 additions & 5 deletions packages/components/src/tree-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ 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';
import { ContextSystemProvider } from '../context';

const CONTEXT_VALUE = {
BaseControl: {
// Temporary during deprecation grace period: Overrides the underlying `__associatedWPComponentName`
// via the context system to override the value set by SelectControl.
_overrides: { __associatedWPComponentName: 'TreeSelect' },
},
};

function getSelectOptions(
tree: Tree[],
Expand Down Expand Up @@ -91,11 +100,13 @@ export function TreeSelect( props: TreeSelectProps ) {
}, [ noOptionLabel, tree ] );

return (
<SelectControl
{ ...{ label, options, onChange } }
value={ selectedId }
{ ...restProps }
/>
<ContextSystemProvider value={ CONTEXT_VALUE }>
<SelectControl
{ ...{ label, options, onChange } }
value={ selectedId }
{ ...restProps }
/>
</ContextSystemProvider>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const TreeSelectWithState: StoryFn< typeof TreeSelect > = ( props ) => {

export const Default = TreeSelectWithState.bind( {} );
Default.args = {
__nextHasNoMarginBottom: true,
label: 'Label Text',
noOptionLabel: 'No parent page',
help: 'Help text to explain the select control.',
Expand Down

0 comments on commit 0b5efce

Please sign in to comment.