re run callbacks on tab change
This commit is contained in:
parent
d08a064bbb
commit
1065e6d450
|
@ -44,6 +44,9 @@ const Settings = ( { params } ) => {
|
||||||
setSidebarContent,
|
setSidebarContent,
|
||||||
sidebarVisisble
|
sidebarVisisble
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const event = new Event( 'reactRendered' );
|
||||||
|
window.dispatchEvent( event );
|
||||||
}, [ params.page, section, sidebarVisisble ] );
|
}, [ params.page, section, sidebarVisisble ] );
|
||||||
|
|
||||||
// Register the slot fills for the settings page just once.
|
// Register the slot fills for the settings page just once.
|
||||||
|
@ -58,11 +61,6 @@ const Settings = ( { params } ) => {
|
||||||
setSidebarVisisble( false );
|
setSidebarVisisble( false );
|
||||||
}, [ params.page, section ] );
|
}, [ params.page, section ] );
|
||||||
|
|
||||||
useEffect( () => {
|
|
||||||
const event = new Event( 'reactRendered' );
|
|
||||||
window.dispatchEvent( event );
|
|
||||||
}, [] );
|
|
||||||
|
|
||||||
if ( ! settingsData ) {
|
if ( ! settingsData ) {
|
||||||
return <div>Error getting data</div>;
|
return <div>Error getting data</div>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,17 @@ function releaseReady() {
|
||||||
// Restore the original jQuery.fn.ready method
|
// Restore the original jQuery.fn.ready method
|
||||||
jQuery.fn.ready = originalReady;
|
jQuery.fn.ready = originalReady;
|
||||||
|
|
||||||
// Execute all queued callbacks
|
// Execute all queued callbacks but save them for when switching tabs.
|
||||||
while ( callbacks.length ) {
|
const callbacksCopy = [ ...callbacks ];
|
||||||
callbacks.shift()( jQuery );
|
while ( callbacksCopy.length ) {
|
||||||
|
callbacksCopy.shift()( jQuery );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jQuery( window ).on( 'reactRendered', function () {
|
jQuery( window ).on( 'reactRendered', function () {
|
||||||
releaseReady();
|
try {
|
||||||
|
releaseReady();
|
||||||
|
} catch ( error ) {
|
||||||
|
// swallow errors here - I'm sorry.
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in New Issue