Skip to content

Commit

Permalink
Restore href instead of path
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnmoon committed Oct 23, 2019
1 parent 90605a8 commit dd54001
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion modules/search/class.jetpack-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ public function load_assets() {
'postTypeFilters' => $widget_options['post_types'],
'postTypes' => $post_type_labels,
'siteId' => Jetpack::get_option( 'id' ),
'siteUrl' => site_url(),
'sort' => $widget_options['sort'],
'widgets' => array_values( $widgets ),
);
Expand Down
4 changes: 2 additions & 2 deletions modules/search/instant-search/components/search-app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
setSortQuery,
getSortQuery,
hasFilter,
restorePreviousPath,
restorePreviousHref,
getSearchQuery,
} from '../lib/query-string';
import { removeChildren, hideElements, hideChildren, showChildren } from '../lib/dom';
Expand Down Expand Up @@ -97,7 +97,7 @@ class SearchApp extends Component {

this.setState( { showResults: false }, () => {
showChildren( this.props.themeOptions.resultsSelector );
restorePreviousPath( this.props.initialPath );
restorePreviousHref( this.props.initialHref );
} );
}

Expand Down
2 changes: 1 addition & 1 deletion modules/search/instant-search/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const injectSearchApp = grabFocus => {
render(
<SearchApp
grabFocus={ grabFocus }
initialPath={ window[ SERVER_OBJECT_NAME ].siteUrl }
initialHref={ window.location.href }
initialSort={ determineDefaultSort( window[ SERVER_OBJECT_NAME ].sort, getSearchQuery() ) }
isSearchPage={ getSearchQuery() !== '' }
options={ window[ SERVER_OBJECT_NAME ] }
Expand Down
4 changes: 2 additions & 2 deletions modules/search/instant-search/lib/query-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ function pushQueryString( queryString ) {
}
}

export function restorePreviousPath( newUrl ) {
export function restorePreviousHref( initialHref ) {
if ( history.pushState ) {
window.history.pushState( { path: newUrl }, '', newUrl );
window.history.pushState( { href: initialHref }, '', initialHref );
window.dispatchEvent( new Event( 'queryStringChange' ) );
}
}
Expand Down

0 comments on commit dd54001

Please sign in to comment.