Skip to content

Conversation

@sethidden
Copy link
Contributor

@sethidden sethidden commented Jun 1, 2022

useFacet is meant to be used with url sorting params in the product category
page, not with simple product searches. useFacet implicitly has some category
search logic while the search bar doesn't care about categories

follow-up to #1075

@SearchBar:toggle="isSearchOpen = $event"
@SearchBar:result="result = $event"
:is-search-open="isSearchOpen"
@set-is-open="isSearchOpen = $event"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this wasn't a toggle per se, it always set the emitted value
to be a toggle, it'd have to be "isSearchOpen = !isSearchOpen"

},
directives: { clickOutside },
props: {
isSearchOpen: {
Copy link
Contributor Author

@sethidden sethidden Jun 1, 2022

Choose a reason for hiding this comment

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

remove isSearchOpen ref from SearchBar itself as it was duplicated.

There's was isSearchOpen in AppHeader.vue that's necessary for both SearchBar and SearchResults, so there's no point keeping a duplicate of the same ref inside SearchBar - they could desync somehow etc.

So 2 way binding is used here now

},
},
setup({ itemsPerPage, minTermLen }, { emit }) {
setup(props, { emit }) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't destructure props because of reactivity loss

const closeSearch = (event: MouseEvent) => {
if (document) {
const searchResultsEl = document.querySelectorAll('.search');
const searchResultsEl = document.querySelector('.search');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No point searching for all instances of .search if you only check the first element in the array below

This will be removed later since communicating thorugh document. isn't the best

@sethidden sethidden force-pushed the M2-672-and-M2-700-search-bar-doesnt-work-plus-typing branch from 6ffff3c to 5e22ace Compare June 1, 2022 14:07
@sethidden sethidden changed the title fix: search fix: search bar not returning results Jun 1, 2022
useFacet is meant to be used with url sorting params in the product category
page, not with simple product searches. useFacet implicitly has some category
search logic while the search bar doesn't care about products
const productList : Products = await getProductList({
pageSize: props.itemsPerPage,
search: term.value,
}) as unknown as Products;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have to override type because getProductList returns some "ProductListQUERY" type instead of something that contains ProductInterface

@Frodigo Frodigo added this to the 1.0.0-rc.9 milestone Jun 1, 2022
@Frodigo Frodigo changed the title fix: search bar not returning results fix!: search bar not returning results Jun 1, 2022
@sethidden sethidden force-pushed the M2-672-and-M2-700-search-bar-doesnt-work-plus-typing branch from 5e22ace to 367efb9 Compare June 2, 2022 07:53
the wishlist store initially downloads only product counts. the actual products
are loaded later on demand, because that's a slow request.

the problem is if you search the wishlist while the actual wishlist products
aren't loaded yet, every search result will appear as if it's not in the
wishlist (heart icon instead of heart_fill)
@sethidden sethidden force-pushed the M2-672-and-M2-700-search-bar-doesnt-work-plus-typing branch from 367efb9 to b863587 Compare June 2, 2022 07:56
@sethidden sethidden merged commit 1742f45 into develop Jun 2, 2022
@sethidden sethidden deleted the M2-672-and-M2-700-search-bar-doesnt-work-plus-typing branch June 2, 2022 08:20
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.

3 participants