Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Fix): Sorting Order and Sorting On are not working in Search Block edit mode #5262

Merged
merged 43 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d37281d
Update withSearch.jsx
dobri1408 Oct 3, 2023
061a9be
Merge branch 'main' into fix-search-block-state
dobri1408 Oct 3, 2023
5e69b51
Create 5262.fix
dobri1408 Oct 3, 2023
6528e13
Merge branch 'main' into fix-search-block-state
dobri1408 Oct 3, 2023
fdb633a
Update SearchBlockEdit.jsx
dobri1408 Oct 3, 2023
7c24c5f
Update withSearch.jsx
dobri1408 Oct 3, 2023
0830a3b
Update SearchBlockEdit.jsx
dobri1408 Oct 3, 2023
daf8d31
Delete news/5262.fix
dobri1408 Oct 3, 2023
e38dcc8
Create 5262.bugfix
dobri1408 Oct 3, 2023
6b3f43d
Merge branch 'main' into fix-search-block-state
dobri1408 Oct 3, 2023
55d9656
Merge branch 'main' into fix-search-block-state
dobri1408 Oct 3, 2023
5a2bef0
Merge branch 'main' into fix-search-block-state
dobri1408 Oct 4, 2023
cfc24db
Merge branch 'main' into fix-search-block-state
dobri1408 Oct 9, 2023
44cd2f9
Merge branch 'main' into fix-search-block-state
dobri1408 Oct 17, 2023
67a8ecf
Merge branch 'main' into fix-search-block-state
dobri1408 Oct 27, 2023
3e25fec
Merge branch 'main' into fix-search-block-state
dobri1408 Oct 31, 2023
ac1de3a
Merge branch 'main' into fix-search-block-state
dobri1408 Nov 5, 2023
de83266
Merge branch 'main' into fix-search-block-state
dobri1408 Nov 8, 2023
196dc8c
Merge branch 'main' into fix-search-block-state
claudiaifrim Nov 15, 2023
0814c59
fix conflict
dobri1408 Feb 26, 2024
935e005
fix conflicts
dobri1408 Feb 26, 2024
39fe8a5
Merge branch 'fix-search-block-state' of https://github.com/plone/vol…
dobri1408 Feb 27, 2024
3ba286a
Merge branch 'main' into fix-search-block-state
dobri1408 Feb 27, 2024
e1d338f
Merge branch 'main' into fix-search-block-state
dobri1408 Feb 27, 2024
1a02549
Merge branch 'main' into fix-search-block-state
dobri1408 Feb 27, 2024
12d0836
make sort order and sort on work on edit
dobri1408 Feb 27, 2024
ee0aab5
Merge branch 'fix-search-block-state' of https://github.com/plone/vol…
dobri1408 Feb 27, 2024
0bd14f6
Update pnpm-lock.yaml
dobri1408 Feb 27, 2024
d050b18
changelog
dobri1408 Feb 27, 2024
0c6df91
Merge branch 'fix-search-block-state' of https://github.com/plone/vol…
dobri1408 Feb 27, 2024
1df5b11
add cypress test
dobri1408 Feb 27, 2024
3aea763
Delete cypress.config.ts
dobri1408 Feb 27, 2024
779ce77
Delete cypress/fixtures/example.json
dobri1408 Feb 27, 2024
4a18512
Delete cypress/support/commands.ts
dobri1408 Feb 27, 2024
f21338b
Delete cypress/support/e2e.ts
dobri1408 Feb 27, 2024
6ae818d
Update pnpm-lock.yaml
dobri1408 Feb 27, 2024
1348b20
fix tests
dobri1408 Feb 28, 2024
ba7cf0a
Merge branch 'fix-search-block-state' of https://github.com/plone/vol…
dobri1408 Feb 28, 2024
9e02fa3
Merge branch 'main' into fix-search-block-state
dobri1408 Feb 28, 2024
9fa7f26
Merge branch 'main' into fix-search-block-state
avoinea Mar 7, 2024
98623f3
Merge branch 'main' into fix-search-block-state
dobri1408 Mar 8, 2024
8bc5c86
make option No Selection to work on edit
dobri1408 Mar 12, 2024
75579a7
Merge branch 'main' into fix-search-block-state
dobri1408 Mar 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions packages/volto/cypress/tests/core/blocks/blocks-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
1 change: 1 addition & 0 deletions packages/volto/news/5262.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(fix): make search block sort and facets work on edit @dobri1408
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading