fix filtering

This commit is contained in:
paul sealock 2024-09-05 13:22:52 +12:00
parent 4242eb3ba6
commit a9bc571447
3 changed files with 20 additions and 20 deletions

View File

@ -8,7 +8,6 @@ import { useSettingsLocation } from '../../routes';
*/
import { getNewPath } from '@woocommerce/navigation';
import { Link } from '@woocommerce/components';
import { addFilter } from '@wordpress/hooks';
export const MyExample = () => {
const { section } = useSettingsLocation();
@ -32,20 +31,3 @@ export const MyExampleEdit = () => {
</>
);
};
addFilter( 'woocommerce_admin_settings_pages', 'woocommerce', ( pages ) => {
return [
...pages,
{
page: 'my-example',
areas: {
content: <MyExample />,
edit: <MyExampleEdit />,
},
widths: {
content: undefined,
edit: 380,
},
},
];
} );

View File

@ -2,12 +2,13 @@
* External dependencies
*/
import { getQuery } from '@woocommerce/navigation';
import { applyFilters } from '@wordpress/hooks';
import { applyFilters, addFilter } from '@wordpress/hooks';
/**
* Internal dependencies
*/
import { Content } from './content';
import { MyExample, MyExampleEdit } from './pages/my-example';
const NotFound = () => {
return <h1>Not Found</h1>;
@ -60,6 +61,23 @@ export const getRoute = () => {
};
}
addFilter( 'woocommerce_admin_settings_pages', 'woocommerce', ( pages ) => {
return [
...pages,
{
page: 'my-example',
areas: {
content: <MyExample />,
edit: <MyExampleEdit />,
},
widths: {
content: undefined,
edit: 380,
},
},
];
} );
const routes = applyFilters( 'woocommerce_admin_settings_pages', [] );
const pageRoute = routes.find( ( route ) => route.page === page );

View File

@ -9,7 +9,7 @@ export const SectionNav = ( { data, section, children } ) => {
const sectionKeys = Object.keys( sections );
const selectedSection = section || sectionKeys[ 0 ];
const onSelect = ( tabName ) => {
const url = getNewPath( { section: tabName } );
const url = getNewPath( { section: tabName, quickEdit: 'false' } );
navigateTo( { url } );
};