appbaseio / appbaseio/reactivesearch

Custom sorting in Reactivesearch: possibly expose `sort` key on `ReactiveComponent`'s `setQuery`

Open
#1,552 3 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
4.9k
Forks
478
PR merge metrics
No merged PRs in 30d

Description

**Affected Projects**
All

**Is your feature request related to a problem? Please describe.**

**Main problem to solve**: I would like to create a custom sorting component for the `ReactiveList`. There have been several issues that have been opened about this already such as: https://github.com/appbaseio/reactivesearch/issues/258 where @metagrover wrote about updating the `defaultQuery` of the result component.

I tried this but it seems like the inner `defaultQuery` does not update upon setting a new state.

**Describe the solution you'd like**
I think the most intuitive way to do this is to expose the `sort` key on `ReactiveComponent`'s `setQuery`. Right now, only changes to `query` are made so it isn't as flexible as it can be.

**Describe alternatives you've considered**
An alternative solution is to allow the `defaultQuery` to be updated when its function/props change.

I might have been doing this wrong so I've provided a codesandbox with both @metagrover 's proposed solution updating the `defaultQuery` of `ReactiveList` as well as showing how a potential `setQuery` with the sort key may look like.

https://codesandbox.io/s/tender-ritchie-15b32?file=/src/index.js

Please let me know if there's any other solution that might be better than these. Thanks!

Contributor guide

Open the contributing guide

Research direction

Start by tracing ReactiveComponent's setQuery and the ReactiveList defaultQuery behavior described in the issue, using the linked CodeSandbox to reproduce the custom sorting case. Determine how query updates are handled and verify that the requested sorting behavior works for a custom ReactiveList component.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, search
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.