From 186d1af57761319344e4b089967a9899e817ba27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Katja=20Su=CC=88ss?= Date: Fri, 12 Apr 2024 10:36:51 +0200 Subject: [PATCH] Search in language fields, but do filter on language only if isMultilingual --- src/components/Searchkit/CustomESRequestSerializer.jsx | 7 ++++++- src/components/Views/FacetedSearch.jsx | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Searchkit/CustomESRequestSerializer.jsx b/src/components/Searchkit/CustomESRequestSerializer.jsx index a47d437a..761245c8 100644 --- a/src/components/Searchkit/CustomESRequestSerializer.jsx +++ b/src/components/Searchkit/CustomESRequestSerializer.jsx @@ -1,6 +1,10 @@ import { extend, isEmpty, keyBy, trim } from 'lodash'; import { getObjectFromObjectList } from '../helpers.jsx'; +import config from '@plone/volto/registry'; + +const volto_config = config; + export class CustomESRequestSerializer { constructor(config) { this.reviewstatemapping = config.reviewstatemapping; @@ -254,7 +258,8 @@ export class CustomESRequestSerializer { // Generate terms of global filters let terms = []; // If isMultilingual, search only in language - this.language && terms.push({ + + this.language && volto_config.settings.isMultilingual && terms.push({ terms: { language: [this.language], }, diff --git a/src/components/Views/FacetedSearch.jsx b/src/components/Views/FacetedSearch.jsx index 909dcbde..c5fca971 100644 --- a/src/components/Views/FacetedSearch.jsx +++ b/src/components/Views/FacetedSearch.jsx @@ -709,7 +709,7 @@ const FacetedSearch = ({ data, overriddenComponents }) => { }; // TODO Check if check on client could be made simpler - const language = useSelector((state) => config.settings.isMultilingual ? state.intl.locale : null); + const language = useSelector((state) => state.intl.locale); const [isClient, setIsClient] = React.useState(null); React.useEffect(() => setIsClient(true), []);