/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { Tooltip } from '@wordpress/components'; import { Icon, chevronLeft } from '@wordpress/icons'; import { getHistory, updateQueryString } from '@woocommerce/navigation'; import { ENTER, SPACE } from '@wordpress/keycodes'; import { recordEvent } from '@woocommerce/tracks'; /** * Internal dependencies */ import './back-button.scss'; export type BackButtonProps = { title: string; }; export const BackButton: React.FC< BackButtonProps > = ( { title } ) => { const homeText = __( 'WooCommerce Home', 'woocommerce-admin' ); const navigateHome = () => { recordEvent( 'topbar_back_button', { page_name: title, } ); updateQueryString( {}, getHistory().location.pathname, {} ); }; // if it's a task list page, render a back button to the homescreen return (
{ if ( keyCode === ENTER || keyCode === SPACE ) { navigateHome(); } } } >
); };