From 45600fa0700e41a9db58e777ec53eef0021ebee5 Mon Sep 17 00:00:00 2001 From: dobri1408 <50819975+dobri1408@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:12:35 +0200 Subject: [PATCH 1/3] (Fix): Sorting Order and Sorting On are not working in Search Block edit mode (#5262) Co-authored-by: Claudia Ifrim Co-authored-by: Alin Voinea --- .../tests/core/blocks/blocks-search.js | 61 +++++++++++++++++++ packages/volto/news/5262.bugfix | 1 + .../manage/Blocks/Search/SearchBlockEdit.jsx | 10 ++- .../manage/Blocks/Search/hocs/withSearch.jsx | 4 +- 4 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 packages/volto/news/5262.bugfix diff --git a/packages/volto/cypress/tests/core/blocks/blocks-search.js b/packages/volto/cypress/tests/core/blocks/blocks-search.js index 9574b1b6d2..3867349870 100644 --- a/packages/volto/cypress/tests/core/blocks/blocks-search.js +++ b/packages/volto/cypress/tests/core/blocks/blocks-search.js @@ -497,4 +497,65 @@ describe('Search Block Tests', () => { `Search results: ${results_number}`, ); }); + + it('Search block - test on edit sort on and sort order', () => { + cy.visit('/'); + cy.get('#toolbar-add > .icon').click(); + cy.get('#toolbar-add-document').click(); + cy.getSlateTitle().focus().click().type('My Search Page'); + + // Add Search listing block + cy.addNewBlock('search'); + + // Add search query criteria + cy.get('#default-query-0-query .react-select__value-container').click(); + cy.get('#default-query-0-query .react-select__option') + .contains('Type') + .click(); + + cy.get('#default-query-0-query .fields:first-of-type > .field').click(); + cy.get( + '#default-query-0-query .fields:first-of-type > .field .react-select__option', + ) + .contains('Page') + .click(); + + cy.get('#default-query-0-query .fields:first-of-type > .field').click(); + cy.get( + '#default-query-0-query .fields:first-of-type > .field .react-select__option', + ) + .contains('Folder') + .click(); + + cy.get('#default-query-0-query .fields:first-of-type > .field').click(); + cy.get( + '#default-query-0-query .fields:first-of-type > .field .react-select__option', + ) + .contains('Event') + .click(); + + // uncheck showSearchButton + cy.get('label[for=field-showSearchButton]').click(); + cy.get('.search-wrapper .ui.button').should('contain', 'Search'); + // reverse order + cy.get('label[for=field-sort_order_boolean-2-query]').click(); + //check if the sorting order is working + cy.get('.listing-item').first().contains('My Event'); + cy.get('#select-listingblock-sort-on').click(); + cy.get('.react-select__menu .react-select__group') + .first() + .children() + .first() + .next() + .children() + .first() + .next() + .click(); + cy.wait(5000); + + cy.get('.listing-item').first().contains('My page'); + //save page + cy.get('#toolbar-save > .icon').click(); + cy.wait(500); + }); }); diff --git a/packages/volto/news/5262.bugfix b/packages/volto/news/5262.bugfix new file mode 100644 index 0000000000..8648d6af38 --- /dev/null +++ b/packages/volto/news/5262.bugfix @@ -0,0 +1 @@ +(fix): make search block sort and facets work on edit @dobri1408 \ No newline at end of file diff --git a/packages/volto/src/components/manage/Blocks/Search/SearchBlockEdit.jsx b/packages/volto/src/components/manage/Blocks/Search/SearchBlockEdit.jsx index b0d7ec2ed5..2fbe1ce4c0 100644 --- a/packages/volto/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +++ b/packages/volto/src/components/manage/Blocks/Search/SearchBlockEdit.jsx @@ -63,9 +63,15 @@ const SearchBlockEdit = (props) => { const { query = {} } = data || {}; // We don't need deep compare here, as this is just json serializable data. const deepQuery = JSON.stringify(query); + useEffect(() => { - onTriggerSearch(); - }, [deepQuery, onTriggerSearch]); + onTriggerSearch( + '', + data?.facets, + data?.query?.sort_on, + data?.query?.sort_order, + ); + }, [deepQuery, onTriggerSearch, data]); return ( <> diff --git a/packages/volto/src/components/manage/Blocks/Search/hocs/withSearch.jsx b/packages/volto/src/components/manage/Blocks/Search/hocs/withSearch.jsx index d06c5bc7ba..961df207b5 100644 --- a/packages/volto/src/components/manage/Blocks/Search/hocs/withSearch.jsx +++ b/packages/volto/src/components/manage/Blocks/Search/hocs/withSearch.jsx @@ -404,12 +404,12 @@ const withSearch = (options) => (WrappedComponent) => { query: data.query || {}, facets: toSearchFacets || facets, searchText: toSearchText ? toSearchText.trim() : '', - sortOn: toSortOn || sortOn, + sortOn: toSortOn || undefined, sortOrder: toSortOrder || sortOrder, facetSettings, }); if (toSearchFacets) setFacets(toSearchFacets); - if (toSortOn) setSortOn(toSortOn); + if (toSortOn) setSortOn(toSortOn || undefined); if (toSortOrder) setSortOrder(toSortOrder); setSearchData(newSearchData); setLocationSearchData(getSearchFields(newSearchData)); From 690a5b06819403b6769aec2edd46404535026831 Mon Sep 17 00:00:00 2001 From: Steffen Lindner Date: Tue, 12 Mar 2024 16:14:13 +0100 Subject: [PATCH 2/3] Add missing nextjs install step (#5857) --- apps/nextjs/README.md | 1 + packages/volto/news/5857.documentation | 1 + 2 files changed, 2 insertions(+) create mode 100644 packages/volto/news/5857.documentation diff --git a/apps/nextjs/README.md b/apps/nextjs/README.md index c881b283fc..687905853e 100644 --- a/apps/nextjs/README.md +++ b/apps/nextjs/README.md @@ -8,6 +8,7 @@ To start, from the root of the monorepo: ```shell pnpm install +pnpm build:deps && pnpm build:components pnpm --filter plone-nextjs run dev ``` diff --git a/packages/volto/news/5857.documentation b/packages/volto/news/5857.documentation new file mode 100644 index 0000000000..97e7c08527 --- /dev/null +++ b/packages/volto/news/5857.documentation @@ -0,0 +1 @@ + Add missing nextjs install step. @gomez From 2db7d9704d7485d4da99016755a6d8ac5efeda89 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 13 Mar 2024 02:47:04 -0400 Subject: [PATCH 3/3] Fix broken link to TanStack Query (#5871) --- docs/source/client/future-improvements.md | 5 ++++- packages/volto/news/5871.documentation | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 packages/volto/news/5871.documentation diff --git a/docs/source/client/future-improvements.md b/docs/source/client/future-improvements.md index e7a245716c..19eab3347c 100644 --- a/docs/source/client/future-improvements.md +++ b/docs/source/client/future-improvements.md @@ -53,7 +53,10 @@ The steps for this approach are as follows: 3. Render the component to string on the server 4. Pass the data from collected queries to TanStack Query cache hydration -Refer to official docs for more information: https://tanstack.com/query/v4/docs/framework/react/guides/ssr +```{seealso} +[TanStack Query Server Rendering & Hydration documentation](https://tanstack.com/query/latest/docs/framework/react/guides/ssr) +``` + ### Automatic caching approach diff --git a/packages/volto/news/5871.documentation b/packages/volto/news/5871.documentation new file mode 100644 index 0000000000..e7f5d9168b --- /dev/null +++ b/packages/volto/news/5871.documentation @@ -0,0 +1 @@ +Fix broken link to TanStack Query. @stevepiercy