Persist active tab on refresh (#36112)
This commit is contained in:
parent
1e815be516
commit
c7c0322163
|
@ -4,6 +4,7 @@
|
|||
import { __ } from '@wordpress/i18n';
|
||||
import { Children, useEffect } from '@wordpress/element';
|
||||
import { TabPanel, Tooltip } from '@wordpress/components';
|
||||
import { navigateTo, getNewPath, getQuery } from '@woocommerce/navigation';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -14,6 +15,8 @@ import { ProductFormTab } from '../product-form-tab';
|
|||
export const ProductFormLayout: React.FC< {
|
||||
children: JSX.Element | JSX.Element[];
|
||||
} > = ( { children } ) => {
|
||||
const query = getQuery() as Record< string, string >;
|
||||
|
||||
useEffect( () => {
|
||||
window.document.body.classList.add(
|
||||
'woocommerce-admin-product-layout'
|
||||
|
@ -63,7 +66,13 @@ export const ProductFormLayout: React.FC< {
|
|||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore Disabled properties will be included in newer versions of Gutenberg.
|
||||
tabs={ tabs }
|
||||
onSelect={ () => ( window.document.documentElement.scrollTop = 0 ) }
|
||||
initialTabName={ query.tab ?? tabs[ 0 ].name }
|
||||
onSelect={ ( tabName: string ) => {
|
||||
window.document.documentElement.scrollTop = 0;
|
||||
navigateTo( {
|
||||
url: getNewPath( { tab: tabName } ),
|
||||
} );
|
||||
} }
|
||||
>
|
||||
{ ( tab ) => (
|
||||
<>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Persist active tab on refresh
|
Loading…
Reference in New Issue