Skip to content

Commit

Permalink
Navigation: Prepare for hard deprecation (#68158)
Browse files Browse the repository at this point in the history
* Navigation: Log deprecation warning

* Add changelog

Co-authored-by: mirka <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: tyxla <[email protected]>
  • Loading branch information
4 people authored Dec 20, 2024
1 parent fd48e8f commit f4f433b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,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

1 comment on commit f4f433b

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in f4f433b.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12434352203
📝 Reported issues:

Please sign in to comment.