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