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

[react-search-ui] setSort not working, Sorting not working #1109

Open
craquet opened this issue Feb 7, 2025 · 0 comments
Open

[react-search-ui] setSort not working, Sorting not working #1109

craquet opened this issue Feb 7, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@craquet
Copy link

craquet commented Feb 7, 2025

Describe the bug
The SearchContext of react-search-ui provides a method called setSort to sort the results. It provides a signature for setting the sorting like this:

search.driver.setSort("field", "asc") // Version 1

and like this:

search.driver.setSort([{ field: "field", direction: "asc" }], "asc") // Version 2

There are two problems here

  1. When specifying the sort using Version 1, it does not work (does nothing, as described in Can't get sorting to work #932 , which is closed but not fixed)
  2. When specifying the sort using Version 2, the second parameter ("asc") is obsolete and should not have to be specified. Though I assume it has no effect anyways.

To Reproduce

Expose the search context to the window object and try the above methods using the browser console. Using Version 1 will update the state, but will not issue a new search. Version 2 works, although the method signature is wrong.

Also See #932 as this issue also applies here (the Sorting component does not work).

Expected behavior
Version 1 and Version 2 as outlined above should work as expected and issue a new search with the correct sorting.

The Sorting component should behave as expected and issue a new search when a sort option is selected.

Related
See also #932

Which backends and packages are you using:
Backend: [Elasticsearch]
Packages: [react-search-ui]

@craquet craquet added the bug Something isn't working label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant