-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat(search): add additional support for multi-faceted search #106
feat(search): add additional support for multi-faceted search #106
Conversation
Looks like I broke something: changing the operator or picking a tag from the dropdown doesn't kick off a new request |
@@ -72,11 +69,11 @@ const SearchFacetsControl = () => { | |||
} | |||
|
|||
if (facet) { | |||
const isPresent = !!searchFacets.find(v => v.name === facet.name) | |||
const disabled = !facet.operatorTypes && !!searchFacets.find(v => v.name === facet.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to generalize the facets that should only be used once (inUse
, hasTransparency
, etc.). Let me know if I should expand this logic.
package.json
Outdated
@@ -59,6 +59,7 @@ | |||
"redux": "^4.0.5", | |||
"redux-observable": "^1.2.0", | |||
"rxjs": "^6.5.3", | |||
"uuid": "^9.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to use @sanity/uuid
here? (Which is already included as a dependency in @sanity/core
and @sanity/desk-tool
@@ -13,7 +13,7 @@ import SearchFacet from '../SearchFacet' | |||
import TextInputNumber from '../TextInputNumber' | |||
|
|||
type Props = { | |||
facet: SearchFacetInputNumberProps | |||
facet: SearchFacetInputNumberProps & {id:string} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bit of a smell in that we're manually augmenting id
across each individual component (i.e. this is repeated in SearchFacetString
, SearchFacetSelect
etc)
Ideally we can abstract this out into a generic type that augments SearchFacetInputProps
and adds id
. E.g.
export type WithId<T extends SearchFacetInputProps> = T & {
id: string
}
And the above could be rewritten to be:
facet: WithId<SearchFacetInputSelectProps>
This has the benefit of making it easier to change this type augmentation in future (e.g. if we have to add another field for whatever reason) – it also means we can avoid creating the new type SearchFacetActiveInputProps
. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! Agreed, this is much better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @nkgentile, this is great!
🎉 This PR is included in version 1.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Addresses #72
Narrow search by adding facets multiple times