@eeacms/volto-clms-theme 1.1.45 → 1.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [1.1.47](https://github.com/eea/volto-clms-theme/compare/1.1.46...1.1.47) - 20 September 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - yarn lock [Ion Lizarazu - [`467cf7e`](https://github.com/eea/volto-clms-theme/commit/467cf7e38b1ce5e55861bc5b217b5c16a788282d)]
12
+ ### [1.1.46](https://github.com/eea/volto-clms-theme/compare/1.1.45...1.1.46) - 20 September 2023
13
+
7
14
  ### [1.1.45](https://github.com/eea/volto-clms-theme/compare/1.1.44...1.1.45) - 20 September 2023
8
15
 
9
16
  #### :bug: Bug Fixes
@@ -17,7 +24,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
17
24
  - jest tests [Ion Lizarazu - [`29f9d35`](https://github.com/eea/volto-clms-theme/commit/29f9d351e6b9ebdcb4d81a2d654a0782cd8af855)]
18
25
  - unused code removed and add tests [Ion Lizarazu - [`51f6856`](https://github.com/eea/volto-clms-theme/commit/51f685623c2148138ee3780e07b369a9a8b2c09a)]
19
26
  - add jest test [Ion Lizarazu - [`159792c`](https://github.com/eea/volto-clms-theme/commit/159792c28b3d8bc903111708b1664704ec0fed5e)]
20
- - withsearch component line 298 [Ion Lizarazu - [`fc546b3`](https://github.com/eea/volto-clms-theme/commit/fc546b3ff2b8448381fad9eb56e459466fd2fb49)]
21
27
  ### [1.1.44](https://github.com/eea/volto-clms-theme/compare/1.1.43...1.1.44) - 19 September 2023
22
28
 
23
29
  ### [1.1.43](https://github.com/eea/volto-clms-theme/compare/1.1.42...1.1.43) - 19 September 2023
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-clms-theme",
3
- "version": "1.1.45",
3
+ "version": "1.1.47",
4
4
  "description": "volto-clms-theme: Volto theme for CLMS site",
5
5
  "main": "src/index.js",
6
6
  "author": "CodeSyntax for the European Environment Agency",
@@ -255,7 +255,28 @@ const withSearch = (options) => (WrappedComponent) => {
255
255
  const multiFacets = data.facets
256
256
  ?.filter((facet) => facet?.multiple)
257
257
  .map((facet) => facet?.field?.value);
258
- const [facets, setFacets] = React.useState({});
258
+ const [facets, setFacets] = React.useState(
259
+ Object.assign(
260
+ {},
261
+ ...urlQuery.map(({ i, v }) => ({ [i]: v })), // TODO: the 'o' should be kept. This would be a major refactoring of the facets
262
+
263
+ // support for simple filters like ?Subject=something
264
+ // TODO: since the move to hash params this is no longer working.
265
+ // We'd have to treat the location.search and manage it just like the
266
+ // hash, to support it. We can read it, but we'd have to reset it as
267
+ // well, so at that point what's the difference to the hash?
268
+ ...configuredFacets.map((f) =>
269
+ locationSearchData[f]
270
+ ? {
271
+ [f]:
272
+ multiFacets.indexOf(f) > -1
273
+ ? [locationSearchData[f]]
274
+ : locationSearchData[f],
275
+ }
276
+ : {},
277
+ ),
278
+ ),
279
+ );
259
280
  const previousUrlQuery = usePrevious(urlQuery);
260
281
 
261
282
  React.useEffect(() => {
@@ -298,9 +319,10 @@ const withSearch = (options) => (WrappedComponent) => {
298
319
  getInitialState(data, facets, urlSearchText, id),
299
320
  );
300
321
 
322
+ const deepFacets = JSON.stringify(facets);
301
323
  React.useEffect(() => {
302
324
  setSearchData(getInitialState(data, facets, urlSearchText, id));
303
- }, [facets, data, urlSearchText, id]);
325
+ }, [deepFacets, facets, data, urlSearchText, id]);
304
326
 
305
327
  const timeoutRef = React.useRef();
306
328
  const facetSettings = data?.facets;
@@ -316,7 +338,7 @@ const withSearch = (options) => (WrappedComponent) => {
316
338
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
317
339
  timeoutRef.current = setTimeout(
318
340
  () => {
319
- const searchData = normalizeState({
341
+ const newSearchData = normalizeState({
320
342
  id,
321
343
  query: data.query || {},
322
344
  facets: toSearchFacets || facets,
@@ -328,8 +350,8 @@ const withSearch = (options) => (WrappedComponent) => {
328
350
  if (toSearchFacets) setFacets(toSearchFacets);
329
351
  if (toSortOn) setSortOn(toSortOn);
330
352
  if (toSortOrder) setSortOrder(toSortOrder);
331
- setSearchData(searchData);
332
- setLocationSearchData(getSearchFields(searchData));
353
+ setSearchData(newSearchData);
354
+ setLocationSearchData(getSearchFields(newSearchData));
333
355
  },
334
356
  toSearchFacets ? inputDelay / 3 : inputDelay,
335
357
  );