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

Navigation: Prepare for hard deprecation #68158

Merged
merged 2 commits into from
Dec 20, 2024
Merged
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 @@ -13,6 +13,7 @@
- `InputControl`: Deprecate 36px default size ([#66897](https://github.com/WordPress/gutenberg/pull/66897)).
- `RadioGroup`: Log deprecation warning ([#68067](https://github.com/WordPress/gutenberg/pull/68067)).
- Soft deprecate `ButtonGroup` component. Use `ToggleGroupControl` instead ([#65429](https://github.com/WordPress/gutenberg/pull/65429)).
- `Navigation`: Log deprecation warning for removal in WP 7.1. Use `Navigator` instead ([#68158](https://github.com/WordPress/gutenberg/pull/68158)).

### Bug Fixes

Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import clsx from 'clsx';
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';
import { useEffect, useRef, useState } from '@wordpress/element';
import { isRTL } from '@wordpress/i18n';

Expand Down Expand Up @@ -79,6 +80,12 @@ export function Navigation( {
const navigationTree = useCreateNavigationTree();
const defaultSlideOrigin = isRTL() ? 'right' : 'left';

deprecated( 'wp.components.Navigation (and all subcomponents)', {
since: '6.8',
version: '7.1',
alternative: 'wp.components.Navigator',
} );

const setActiveMenu: NavigationContextType[ 'setActiveMenu' ] = (
menuId,
slideInOrigin = defaultSlideOrigin
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/navigation/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ describe( 'Navigation', () => {

const menuItems = screen.getAllByRole( 'listitem' );

expect( console ).toHaveWarnedWith(
'wp.components.Navigation (and all subcomponents) is deprecated since version 6.8 and will be removed in version 7.1. Please use wp.components.Navigator instead.'
);

expect( menuItems ).toHaveLength( 4 );
expect( menuItems[ 0 ] ).toHaveTextContent( 'Item 1' );
expect( menuItems[ 1 ] ).toHaveTextContent( 'Item 2' );
Expand Down
Loading