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

RSK: implement sorting on empty query string #149

Merged
merged 1 commit into from Nov 9, 2020

Conversation

ntarocco
Copy link
Contributor

@ntarocco ntarocco commented Nov 1, 2020

  • introduces a new prop to define which sorting to use on empty query
    string
  • adds a new private app state to the store to keep track if the user
    has selected a new sorting and what was the initial sorting before
    change
  • adds tests
  • changes documentation
  • closes Change sort by/order on empty query #111

@ntarocco ntarocco changed the title RSK: implment sorting on empty query string RSK: implement sorting on empty query string Nov 1, 2020
@ntarocco ntarocco requested review from zzacharo, Glignos, KonstantinaStoikou and kpsherva and removed request for zzacharo November 2, 2020 07:32
docs/docs/components/react_search_kit.md Outdated Show resolved Hide resolved
docs/docs/components/react_search_kit.md Outdated Show resolved Hide resolved
src/lib/components/Toggle/Toggle.js Outdated Show resolved Hide resolved
let queryState = getState().query;
updateQueryStateSorting(queryState, appState, config);

queryState = _cloneDeep(queryState);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to return a cloned state from the updateQueryStateSorting ? Then, if someone uses it in another action, there wouldn't need to care about the mutation that is happening inside the function...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed, can you double check? I am not sure I fully understood your comment.

src/lib/state/actions/query.js Show resolved Hide resolved
Copy link
Contributor

@KonstantinaStoikou KonstantinaStoikou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the branch locally and noticed that when you enter a query and then change the sorting and clear the query the last sorting is used in the empty query. Is this the desired behavior or everytime an empty query is entered the sorting should change to the defaultOnEmptyString?

@zzacharo
Copy link
Member

zzacharo commented Nov 5, 2020

I ran the branch locally and noticed that when you enter a query and then change the sorting and clear the query the last sorting is used in the empty query. Is this the desired behavior or everytime an empty query is entered the sorting should change to the defaultOnEmptyString?

I would say that everytime the query string is empty the defaultOnEmptyString should be used :)

@ntarocco ntarocco force-pushed the add-default-sort-by branch 2 times, most recently from 5db74df to 7d3cc63 Compare November 5, 2020 20:18
@ntarocco ntarocco force-pushed the master branch 2 times, most recently from 8a2e65d to d1834e0 Compare November 6, 2020 09:08
@ntarocco
Copy link
Contributor Author

ntarocco commented Nov 6, 2020

I ran the branch locally and noticed that when you enter a query and then change the sorting and clear the query the last sorting is used in the empty query. Is this the desired behavior or everytime an empty query is entered the sorting should change to the defaultOnEmptyString?

I would say that everytime the query string is empty the defaultOnEmptyString should be used :)

Good question @KonstantinaStoikou @zzacharo how I have implemented is:

  • nothing touched, no query string: use sorting given via config onEmptyQuery
  • nothing touched, with query string: use default sorting
  • user changed sorting (user choice), independently of the presence of the query string: use user choice

The idea was that if the user selects a sorting, it means (s)he wants that. If I choose sort by most loaned, I am not sure I wanted to be automatically changed back to most recent or bestmatch. WDYT?

* introduces a new prop to define which sorting to use on empty query
  string
* adds a new private app state to the store to keep track if the user
  has selected a new sorting and what was the initial sorting before
  change
* adds tests
* changes documentation
* closes inveniosoftware#111
@ntarocco ntarocco merged commit f5d8bba into inveniosoftware:master Nov 9, 2020
@ntarocco ntarocco deleted the add-default-sort-by branch November 9, 2020 08:19
@FlorianCassayre FlorianCassayre mentioned this pull request Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change sort by/order on empty query
4 participants