-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Query and Search blocks: support for Instant Search #63053
Comments
I will prepare the initial implementation. |
Another thing that we need to do, but doesn't need to be in the initial implementation is to always add the "No results" block to the page even if it's initially hidden, so all the necessary CSS/JS is properly loaded. |
When using Just throwing this in here for consideration, because when implementing search, the query would be changing and pagination would therefore also be changing and if there was different methods of pagination, they would all need to be accounted for as well, which might get complex or maybe not. Also with search, a "Result count" block or something like that could potentially be needed. |
@ktmn Thanks for your suggestions! It will be very similar to this solution that I posted some times ago as a plugin. You can check by download my repo if you want. You may notice that the pagination behaves dynamically, disappearing if there are less than a given number of posts. |
Yeah, thanks for the insight @ktmn, although I'm not too worried about those kinds of details right now. Let's see if we can get an initial version and then we'll look at the UX and see what we need to improve 🙂 |
I made decent progress on the implementation of the Instant Search: #63147 (please note the updated PR description 🙂) I've also created 2 PRs with an alternative implementation using filters:
#63147
#67013 & #67181
|
As we need to modify the query for both the default and custom cases, I'd rather go with something like this instead (kudos to @roborourke). |
That makes sense. The approach you shared is almost the same as what I've explored in:
https://github.com/humanmade/query-filter uses the same two filters to add the functionality. The main difference is that they are using I'd have to study their implementation some more to understand if there's a significant advantage to one or the approach. In any case, using those two filters is the best approach, in my opinion. So, given what you mentioned, can we close #63147 & #67013 and continue with #67181 & #67289 ? |
@michalczaplinski the reason I did it that way iirc is because if the query loop block is set to inherit the global query you don’t get the |
Hi Rob! 👋 Thanks for chiming in! You're right, that's exactly what we also figured out: What I was wondering about is your specific use of Have you considered using |
@michalczaplinski yeah I guess that could work too, I think I just wanted to use the same single function for the filtering, so it was easier to act on the Your approach sounds like it might be more performant than mine, but you might need to replicate the logic a bit, unless there's a way to update a |
What problem does this address?
Now that we have the Interactivity API in Core, it's time to start experimenting with enhanced user experiences. One of these would be the ability to refresh the content of a Query block without refreshing the page while the user is typing a search.
What is your proposed solution?
I believe the simplest way to start with the Instant Search would be to convert the search into an instant search when the Search block is inside a Query block that has the
Forge Page Reload
option disabled.When the
Force Page Reload
option is disabled, theenhancedPagination
attribute istrue
and is passed via block context. Therefore, the Search block can subscribe to theenhancedPagination
context. If it istrue
, it can add the necessary directives using theHTML_Tag_Processor
and enqueue deview
file.The text was updated successfully, but these errors were encountered: