Skip to content

Commit

Permalink
Remove entirely the goToParent prop on useNavigatorBackButton
Browse files Browse the repository at this point in the history
This can be done because its usage was actually only internal to the component
  • Loading branch information
ciampo committed Aug 16, 2024
1 parent a33aa8d commit da79e35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
16 changes: 2 additions & 14 deletions packages/components/src/navigator/navigator-back-button/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* WordPress dependencies
*/
import { useCallback } from '@wordpress/element';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand All @@ -11,29 +10,18 @@ import type { WordPressComponentProps } from '../../context';
import { useContextSystem } from '../../context';
import Button from '../../button';
import useNavigator from '../use-navigator';
import type { NavigatorBackButtonHookProps } from '../types';
import type { NavigatorBackButtonProps } from '../types';

export function useNavigatorBackButton(
props: WordPressComponentProps< NavigatorBackButtonHookProps, 'button' >
props: WordPressComponentProps< NavigatorBackButtonProps, 'button' >
) {
const {
onClick,
as = Button,

// Deprecated
goToParent,

...otherProps
} = useContextSystem( props, 'NavigatorBackButton' );

if ( goToParent !== undefined ) {
deprecated( '`goToParent` prop in wp.components.NavigatorBackButton', {
since: '6.7',
alternative:
'"back" navigations are always treated as going to the parent screen',
} );
}

const { goBack } = useNavigator();
const handleClick: React.MouseEventHandler< HTMLButtonElement > =
useCallback(
Expand Down
11 changes: 0 additions & 11 deletions packages/components/src/navigator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,6 @@ export type NavigatorScreenProps = {

export type NavigatorBackButtonProps = ButtonAsButtonProps;

export type NavigatorBackButtonHookProps = NavigatorBackButtonProps & {
/**
* _Note: this prop is deprecated and won't have any effect on the component._
* Whether we should navigate to the parent screen.
*
* @deprecated
* @ignore
*/
goToParent?: boolean;
};

export type NavigatorToParentButtonProps = NavigatorBackButtonProps;

export type NavigatorButtonProps = NavigatorBackButtonProps & {
Expand Down

0 comments on commit da79e35

Please sign in to comment.