Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

### Bug Fixes

- Block Editor: Include migration hint in useSetting deprecation warning ([#85100](https://github.com/WordPress/gutenberg/pull/85100)).
- List View: Fix the drag-and-drop nesting gesture over an item without children ([#84856](https://github.com/WordPress/gutenberg/pull/84856)).
- Writing Flow: Preserve rich text selection on Shift+click within the same block ([#84579](https://github.com/WordPress/gutenberg/pull/84579)).
- List View: Show the appender when the container is contentOnly ([#84713](https://github.com/WordPress/gutenberg/pull/84713)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export function useSetting( path: string ) {
deprecated( 'wp.blockEditor.useSetting', {
since: '6.5',
alternative: 'wp.blockEditor.useSettings',
// @ts-expect-error `deprecated` has no `note` option, so this is ignored.
note: 'The new useSettings function can retrieve multiple settings at once, with better performance.',
hint: 'The new useSettings function can retrieve multiple settings at once, with better performance.',
} );

const [ value ] = useSettings( path );
Expand Down

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is testing the deprecated method's internals. I don't think this test is needed.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { describe, expect, it } from 'vitest';
import { renderHook } from '@testing-library/react';
import { createRegistry, RegistryProvider } from '@wordpress/data';
import { useSetting } from '../';
import { store as blockEditorStore } from '../../../store';

describe( 'useSetting', () => {
it( 'includes the migration hint in its deprecation warning', () => {
const registry = createRegistry();
registry.register( blockEditorStore );
registry.dispatch( blockEditorStore ).updateSettings( {
__experimentalFeatures: {
typography: { dropCap: false },
},
} );

const { result } = renderHook(
() => useSetting( 'typography.dropCap' ),
{
wrapper: ( { children } ) => (
<RegistryProvider value={ registry }>
{ children }
</RegistryProvider>
),
}
);

expect( result.current ).toBe( false );
expect( console ).toHaveWarnedWith(
'wp.blockEditor.useSetting is deprecated since version 6.5. Please use wp.blockEditor.useSettings instead. Note: The new useSettings function can retrieve multiple settings at once, with better performance.'
);
} );
} );
Loading