smash nav bugs

This commit is contained in:
paul sealock 2024-05-30 16:32:57 +12:00
parent 63e751a3a2
commit f81321be4c
3 changed files with 15 additions and 9 deletions

View File

@ -8,6 +8,10 @@ export const Content = ( { data } ) => {
console.log( settings ); console.log( settings );
if ( ! settings ) {
return null;
}
return ( return (
<div> <div>
{ settings.map( ( setting, idx ) => { { settings.map( ( setting, idx ) => {

View File

@ -18,12 +18,13 @@ import './style.scss';
const Settings = ( { params } ) => { const Settings = ( { params } ) => {
const settingsData = window.wcSettings?.admin?.settingsPages; const settingsData = window.wcSettings?.admin?.settingsPages;
const { section } = getQuery();
// Be sure to render Settings slots when the params change.
useEffect( () => { useEffect( () => {
possiblyRenderSettingsSlots(); possiblyRenderSettingsSlots();
}, [ params ] ); }, [ params ] );
// Register the slot fills for the settings page just once.
useEffect( () => { useEffect( () => {
registerTaxSettingsConflictErrorFill(); registerTaxSettingsConflictErrorFill();
registerPaymentsSettingsBannerFill(); registerPaymentsSettingsBannerFill();
@ -34,6 +35,13 @@ const Settings = ( { params } ) => {
return <div>Error getting data</div>; return <div>Error getting data</div>;
} }
const { section } = getQuery();
const sections = settingsData[ params.page ]?.sections;
const contentData =
Array.isArray( sections ) && sections.length === 0
? {}
: sections[ section || '' ];
return ( return (
<> <>
<Tabs data={ settingsData } page={ params.page }> <Tabs data={ settingsData } page={ params.page }>
@ -45,13 +53,7 @@ const Settings = ( { params } ) => {
/> />
</div> </div>
<div className="woocommerce-settings-content"> <div className="woocommerce-settings-content">
<Content <Content data={ contentData } />
data={
settingsData[ params.page ].sections[
section || ''
]
}
/>
</div> </div>
</div> </div>
</Tabs> </Tabs>

View File

@ -6,7 +6,7 @@ import { getNewPath, navigateTo } from '@woocommerce/navigation';
export const Tabs = ( { data, page, children } ) => { export const Tabs = ( { data, page, children } ) => {
const onSelect = ( tabName ) => { const onSelect = ( tabName ) => {
const url = getNewPath( {}, `/settings/${ tabName }` ); const url = getNewPath( {}, `/settings/${ tabName }`, {} );
navigateTo( { url } ); navigateTo( { url } );
}; };