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

NumberControl: Deprecate 36px default size #66730

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Deprecations

- `Radio`: Deprecate 36px default size ([#66572](https://github.com/WordPress/gutenberg/pull/66572)).
- `NumberControl`: Deprecate 36px default size ([#66730](https://github.com/WordPress/gutenberg/pull/66730)).

### Enhancements

Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/number-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Example = () => {

return (
<NumberControl
__next40pxDefaultSize
isShiftStepEnabled={ true }
onChange={ setValue }
shiftStep={ 10 }
Expand Down Expand Up @@ -146,4 +147,4 @@ Start opting into the larger default height that will become the default size in

- Type: `Boolean`
- Required: No
- Default: `false`
- Default: `false`
8 changes: 8 additions & 0 deletions packages/components/src/number-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { HStack } from '../h-stack';
import { Spacer } from '../spacer';
import { useCx } from '../utils';
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';

const noop = () => {};

Expand All @@ -34,6 +35,7 @@ function UnforwardedNumberControl(
forwardedRef: ForwardedRef< any >
) {
const {
__next40pxDefaultSize,
__unstableStateReducer: stateReducerProp,
className,
dragDirection = 'n',
Expand All @@ -56,6 +58,12 @@ function UnforwardedNumberControl(
...restProps
} = useDeprecated36pxDefaultSizeProp< NumberControlProps >( props );

maybeWarnDeprecated36pxSize( {
componentName: 'NumberControl',
size,
__next40pxDefaultSize,
} );

if ( hideHTMLArrows ) {
deprecated( 'wp.components.NumberControl hideHTMLArrows prop ', {
alternative: 'spinControls="none"',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ const Template: StoryFn< typeof NumberControl > = ( {
export const Default = Template.bind( {} );
Default.args = {
label: 'Value',
__next40pxDefaultSize: true,
};
2 changes: 1 addition & 1 deletion packages/components/src/number-control/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
}

describe( 'NumberControl', () => {
describe( 'Basic rendering', () => {

Check failure on line 32 in packages/components/src/number-control/test/index.tsx

View workflow job for this annotation

GitHub Actions / JavaScript (Node.js 20) 1/4

Error: expect(jest.fn()).not.toHaveWarned(expected) Expected mock function not to be called but it was called with: ["36px default size for wp.components.NumberControl is deprecated since version 6.8 and will be removed in version 7.1. Note: Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version."] console.warn() should not be used unless explicitly expected See https://www.npmjs.com/package/@wordpress/jest-console for details. at Object.assertExpectedCalls (/home/runner/work/gutenberg/gutenberg/packages/jest-console/src/index.js:32:40) at Promise.then.completed (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:300:28) at new Promise (<anonymous>) at callAsyncCircusFn (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:233:10) at _callCircusHook (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:280:40) at processTicksAndRejections (node:internal/process/task_queues:95:5) at _runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:253:5) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:125:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at run (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:70:3) at runAndTransformResultsToJestFormat (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21) at jestAdapter (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19) at runTestInternal (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:367:16) at runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:444:34) at Object.worker (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/testWorker.js:106:12)

Check failure on line 32 in packages/components/src/number-control/test/index.tsx

View workflow job for this annotation

GitHub Actions / JavaScript (Node.js 22) 1/4

Error: expect(jest.fn()).not.toHaveWarned(expected) Expected mock function not to be called but it was called with: ["36px default size for wp.components.NumberControl is deprecated since version 6.8 and will be removed in version 7.1. Note: Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version."] console.warn() should not be used unless explicitly expected See https://www.npmjs.com/package/@wordpress/jest-console for details. at Object.assertExpectedCalls (/home/runner/work/gutenberg/gutenberg/packages/jest-console/src/index.js:32:40) at Promise.then.completed (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:300:28) at new Promise (<anonymous>) at callAsyncCircusFn (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:233:10) at _callCircusHook (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:280:40) at processTicksAndRejections (node:internal/process/task_queues:105:5) at _runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:253:5) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:125:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at run (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:70:3) at runAndTransformResultsToJestFormat (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21) at jestAdapter (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19) at runTestInternal (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:367:16) at runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:444:34) at Object.worker (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/testWorker.js:106:12)
it( 'should render', () => {
render( <NumberControl /> );
render( <NumberControl __next40pxDefaultSize /> );
expect( screen.getByRole( 'spinbutton' ) ).toBeVisible();
} );

Expand Down
Loading