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

feat(search): add additional support for multi-faceted search #106

Merged
merged 8 commits into from
Dec 21, 2022
Merged

feat(search): add additional support for multi-faceted search #106

merged 8 commits into from
Dec 21, 2022

Conversation

nkgentile
Copy link
Contributor

@nkgentile nkgentile commented Dec 12, 2022

Addresses #72

Narrow search by adding facets multiple times

@nkgentile nkgentile marked this pull request as ready for review December 15, 2022 00:42
@nkgentile
Copy link
Contributor Author

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)
Copy link
Contributor Author

@nkgentile nkgentile Dec 15, 2022

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",
Copy link
Collaborator

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}
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Collaborator

@robinpyon robinpyon left a 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!

@robinpyon robinpyon merged commit 9cb9dc9 into sanity-io:studio-v2 Dec 21, 2022
@github-actions
Copy link

🎉 This PR is included in version 1.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nkgentile nkgentile deleted the feature/add-multi-tag-filter branch December 21, 2022 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants