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

Query and Search blocks: support for Instant Search #63053

Open
luisherranz opened this issue Jul 2, 2024 · 5 comments
Open

Query and Search blocks: support for Instant Search #63053

luisherranz opened this issue Jul 2, 2024 · 5 comments
Assignees
Labels
[Block] Query Loop Affects the Query Loop Block [Block] Search Affects the Search Block - used to display a search field [Feature] Interactivity API API to add frontend interactivity to blocks. [Type] Enhancement A suggestion for improvement.

Comments

@luisherranz
Copy link
Member

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, the enhancedPagination attribute is true and is passed via block context. Therefore, the Search block can subscribe to the enhancedPagination context. If it is true, it can add the necessary directives using the HTML_Tag_Processor and enqueue de view file.

@luisherranz luisherranz added [Type] Enhancement A suggestion for improvement. [Block] Search Affects the Search Block - used to display a search field [Block] Query Loop Affects the Query Loop Block [Feature] Interactivity API API to add frontend interactivity to blocks. labels Jul 2, 2024
@r-chrzan
Copy link

r-chrzan commented Jul 2, 2024

I will prepare the initial implementation.

@luisherranz
Copy link
Member Author

luisherranz commented Jul 2, 2024

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.

@ktmn
Copy link

ktmn commented Jul 2, 2024

it's time to start experimenting

When using enhancedPagination the Pagination block could have a child block called "Load more button" which you could use instead of the "Previous Page", "Page Numbers" and "Next Page" blocks. Instead of going to the next page it could pick the items from the response and append them to the <ul>.

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.

@r-chrzan
Copy link

r-chrzan commented Jul 2, 2024

@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.

@luisherranz
Copy link
Member Author

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 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Query Loop Affects the Query Loop Block [Block] Search Affects the Search Block - used to display a search field [Feature] Interactivity API API to add frontend interactivity to blocks. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants