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

Patch text search and filter search not independent in UI #366

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/components/Search.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import ButtonLinks from "./ButtonLinks.svelte"
import { createEventDispatcher } from "svelte"

let searchTerm = ""
export let searchTerm = ""

const dispatch = createEventDispatcher()

Expand Down
11 changes: 9 additions & 2 deletions src/routes/resources/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
let displayedResources = resources
let filterByTags: Resource[]
let tagLogicAnd: boolean = true // Whether all the selected tags must match the resource (vs any of the selected tags)
let searchTerm: string = ""
// TODO: make this a user preference
$: tagLogic = tagLogicAnd ? "and" : "or"

Expand All @@ -44,7 +45,7 @@
}

function filterBySearchInput(event: CustomEvent<{ searchTerm: string }>) {
const { searchTerm } = event.detail
searchTerm = event.detail.searchTerm

// Analytics
mixpanel.track("Resource Search", {
Expand All @@ -66,6 +67,9 @@
})

displayedResources = searchResults

// Clear filterObject tags
filterObject.forEach((option) => (option.active = false))
}

const filterResources = (
Expand All @@ -76,6 +80,9 @@
) => {
const { filterOptions, filterLogic } = event.detail

// Reset search term
searchTerm = ""

// Reset displayed resources
displayedResources = []

Expand Down Expand Up @@ -125,7 +132,7 @@
<p class="italic">{resources.length} resources and counting!!</p>
</div>
<ResourceNav />
<Search on:search={filterBySearchInput}></Search>
<Search on:search={filterBySearchInput} {searchTerm}></Search>
<FilterForm
filterOptions={filterObject}
filterLogicAnd={tagLogicAnd}
Expand Down