Skip to content

Commit

Permalink
fix: don't use the default sort when loading a page with a search ter…
Browse files Browse the repository at this point in the history
…m - refs #253324
  • Loading branch information
tiberiuichim committed May 29, 2023
1 parent fe3bd7f commit 3bcedd4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion searchlib/components/SearchApp/SearchApp.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import React from 'react';
import { SearchView } from '@eeacms/search/components/SearchView/SearchView';
import { getDefaultFilters } from '@eeacms/search/lib/utils';
import qs from 'querystring';

import BasicSearchApp from './BasicSearchApp';

export default function SearchApp(props) {
const { defaultSort = '' } = props;
const locationSearch = __CLIENT__
? qs.parse(window.location.search || '')?.['q']
: null;
const defaultSort = locationSearch !== null ? '' : props.defaultSort || '';
const [sortField, sortDirection] = defaultSort.split('|');
const appConfig = props.registry.searchui[props.appName];
const appDefaultFilters = getDefaultFilters(appConfig);
Expand Down
6 changes: 4 additions & 2 deletions src/SearchBlock/templates/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,21 @@ export const searchResultsSchemaEnhancer = ({ schema, formData }) => {

if (appConfig) {
const { resultViews } = appConfig;
// console.log(appConfig);

const availableFacets = appConfig.facets?.map(({ field, label }) => [
field,
label,
label?.trim() ? label : field,
]);

// if (appConfig.landingPageURL) {
// schema.properties.landingPageURL.default = appConfig.landingPageURL;
// }

schema.properties.availableFacets.choices = availableFacets;
schema.properties.availableFacets.items = { choices: availableFacets };

schema.properties.defaultFacets.choices = availableFacets;
schema.properties.defaultFacets.items = { choices: availableFacets };

// fill in defaultResultView choices
schema.properties.defaultResultView = {
Expand Down

0 comments on commit 3bcedd4

Please sign in to comment.