Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pushState when preview URL changed #2

Closed
westonruter opened this issue Jul 13, 2016 · 1 comment
Closed

Use pushState when preview URL changed #2

westonruter opened this issue Jul 13, 2016 · 1 comment

Comments

@westonruter
Copy link
Contributor

See

// @todo If newQueryParams.url !== oldQueryParams.url, do history.pushState?
history.replaceState( newQueryParams, document.title, urlParser.href );
}
} );
/**
* Watch for changes to a construct's active and expanded states.
*
* @param {wp.customize.Panel|wp.customize.Section|wp.customize.Control} construct Construct.
* @returns {void}
*/
component.watchExpandedChange = function watchExpandedChange( construct ) {
if ( construct.active ) {
construct.active.bind( component.replaceState );
}
if ( construct.expanded ) {
construct.expanded.bind( component.replaceState );
}
};
/**
* Unwatch for changes to a construct's active and expanded states.
*
* @param {wp.customize.Panel|wp.customize.Section|wp.customize.Control} construct Construct.
* @returns {void}
*/
component.unwatchExpandedChange = function watchExpandedChange( construct ) {
if ( construct.active ) {
construct.active.unbind( component.replaceState );
}
if ( construct.expanded ) {
construct.expanded.unbind( component.replaceState );
}
};
// @todo window.addEventListener( 'popstate', ... ) if pushState used.

On popstate we'd need to make sure that we only update the url and leave the autofocus params intact.

@westonruter
Copy link
Contributor Author

This would be useful in Customize Posts if the preview is automatically navigated to when post sections expand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant